1 # Alter the streaming code to include a "locations" filter. You need
2 # to use the order sw_lng, sw_lat, ne_lng, ne_lat for the four
5 # Note: to answer this, I used this website to find a good box:
6 # http://boundingbox.klokantech.com/
10 from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
12 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
13 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
15 api = tweepy.API(auth)
17 class StreamListener(tweepy.StreamListener):
18 def on_status(self, tweet):
19 print(tweet.author.screen_name + "\t" + tweet.text)
21 def on_error(self, status_code):
22 print('Error: ' + repr(status_code))
26 streamer = tweepy.Stream(auth=auth, listener=l)
28 # This should grab tweets within Seattle:
29 streamer.filter(locations=[-122.459696, 47.481002, -122.224433, 47.734136])