Esempio n. 1
0
    def on_status(self, status):
        """ --- When a Status/Tweet is Captured, It Comes Here --- """

        # --- Create Tweet Obeject From Pieces of the Tweet We Need
    	lat, lon = status.geo["coordinates"] if status.geo else ('', '')

    	# --- FOR TESTING ONLY REMOVE SOON ----
    	print "hashtags = " 
    	print status.entities['hashtags']

    	# --- Save the Relevant Information From the HashTag  (All We Need is the Tag Text)
    	tagList = []
    	for tag in status.entities['hashtags']:
    		tagList.append(tag['text'])

    	tempTweet = Tweet(status.id, status.created_at, status.text, status.entities['user_mentions'], tagList, lat, lon)
        	

        # --- Tweet is Collected With the Handle Stream
        if self.streamID == "handle":
        	helperFunctions.storeTweet(tempTweet, bars)

        # --- Tweet is Collected With the Location Stream: Classify Tweet Relative to Specific Bar OR Just a Happy NorthGater
        elif self.streamID == "location":
        	helperFunctions.classifyTweet(tempTweet, bars, generalBarGoerTweets)		
 			#print "lat = " + str(lat) + '\t' + "lon = " + str(lon) + '\n'

        return True
Esempio n. 2
0
		self.handleStream = tweepy.Stream(auth = self.auth, listener = self.handleListener)
		self.handleStream.filter(follow = barIDs, track = barHandles)


	def CollectTweetsByLocation(self, _lattitude, _longitude, _radius, _units):
		searchLocation = str(_lattitude) + "," + str(_longitude) + "," + str(_radius) + str(_units)

		self.locationStream = tweepy.Stream(self.auth, self.locationListener)
		self.locationStream.filter(follow = None, locations=[-102.33,31.84,-102.28,31.91])


if __name__ == "__main__":
	
	homeLat = 30.587457
	homeLon = -96.342547


	# --- Load the Bar Data From File (Will Change this to Load from DataBase)
	loadAllBarData("BarData.csv", bars)
	helperFunctions.loadStreamFiterLists(bars, barHandles, barIDs)

	tweetCrawler = TweetCrawler()
	tweetCrawler.CollectTweetsByHandle()
	#tweetCrawler.CollectTweetsByLocation(homeLat, homeLon , 0.1 , "mi")