remove readme from the non-solutions
[twitter-api-cdsw-solutions] / solution-geo-2.py
1 # What are people tweeting about in Times Square today?
2
3 # Note: to answer this, I used this website to find a good box:
4 # http://boundingbox.klokantech.com/
5
6 import encoding_fix
7 import tweepy
8 from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
9
10 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
11 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
12
13 api = tweepy.API(auth)
14
15 class StreamListener(tweepy.StreamListener):
16     def on_status(self, tweet):
17         print(tweet.author.screen_name + "\t" + tweet.text)
18
19     def on_error(self, status_code):
20         print('Error: ' + repr(status_code))
21         return False
22
23 l = StreamListener()
24 streamer = tweepy.Stream(auth=auth, listener=l)
25
26 # This should grab tweets in Times Square
27 streamer.filter(locations=[-73.9864799803,40.7575460197,-73.9837820197,40.7602439803])
28

Benjamin Mako Hill || Want to submit a patch?