1 # Set up a bounding box around Times Square and around NYC as a whole.
3 # Alter the streaming code to include a "locations" filter. You need
4 # to use the order sw_lng, sw_lat, ne_lng, ne_lat for the four
7 # Note: to answer this, I used this website to find a good box:
8 # http://boundingbox.klokantech.com/
12 from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
14 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
15 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
17 api = tweepy.API(auth)
19 class StreamListener(tweepy.StreamListener):
20 def on_status(self, tweet):
21 print(tweet.author.screen_name + "\t" + tweet.text)
23 def on_error(self, status_code):
24 print('Error: ' + repr(status_code))
28 streamer = tweepy.Stream(auth=auth, listener=l)
30 # This should grab tweets in Times Square /and/ NYC as a whole
31 streamer.filter(locations=[-73.9864799803,40.7575460197,-73.9837820197,40.7602439803,
32 -74.25909,40.477399,-73.700171,40.917577])