Skip to content

Instantly share code, notes, and snippets.

@hiimivantang
Last active January 14, 2016 08:03
Show Gist options
  • Save hiimivantang/190cf73ccdaaa6006f9e to your computer and use it in GitHub Desktop.
Save hiimivantang/190cf73ccdaaa6006f9e to your computer and use it in GitHub Desktop.
twitter stream consumer
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