Last active
January 14, 2016 08:03
-
-
Save hiimivantang/190cf73ccdaaa6006f9e to your computer and use it in GitHub Desktop.
twitter stream consumer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
from tweepy import auth | |
CONSUMER_KEY="" #FIXME | |
CONSUMER_SECRET="" #FIXME | |
TOKEN_KEY="" #FIXME | |
TOKEN_SECRET="" #FIXME | |
#override tweepy.StreamListener to add logic to on_status | |
class MyStreamListener(tweepy.StreamListener): | |
def on_status(self, status): | |
print(status.text.encode('utf8')) | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(TOKEN_KEY, TOKEN_SECRET) | |
api = tweepy.API(auth) | |
myStream = tweepy.Stream(auth = api.auth, listener=MyStreamListener()) | |
myStream.filter(track=["RIPLKY", "RememberingLKY", "LKY", "RememberingLeeKuanYew"], async=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment