]> projects.mako.cc - twitter-api-cdsw-solutions/blob - twitter-stream2.py
59e0cf27033393cf33d009ba9e0adefa7e37d218
[twitter-api-cdsw-solutions] / twitter-stream2.py
1 import tweepy
2 from twitter_authentication import API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
3
4 auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
5 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
6
7 api = tweepy.API(auth)
8
9 class StreamListener(tweepy.StreamListener):
10     def on_status(self, tweet):
11         print tweet.user.screen_name + "\t" + tweet.text
12
13     def on_error(self, status_code):
14         print 'Error: ' + repr(status_code)
15         return False
16
17 l = StreamListener()
18 streamer = tweepy.Stream(auth=auth, listener=l)
19
20 keywords = ['python', 'perl']
21 streamer.filter(track = keywords)

Benjamin Mako Hill || Want to submit a patch?