Skip to content

Instantly share code, notes, and snippets.

@Adagio-cantabile
Last active October 20, 2016 15:17
Show Gist options
  • Save Adagio-cantabile/cb39c9ec69c84fac0c7618ab7f4d87dc to your computer and use it in GitHub Desktop.
Save Adagio-cantabile/cb39c9ec69c84fac0c7618ab7f4d87dc to your computer and use it in GitHub Desktop.
streaming with tweepy
import tweepy
from tweepy import api
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
c_key = 'your customer key'
c_secret = 'your customer secret'
a_token = 'your access token'
a_secret = 'your access token secret'
class listener(StreamListener):
def on_data(self, data):
print(data)
return True
def on_error(self, status):
print(status)
auth = OAuthHandler(c_key, c_secret)
auth.set_access_token(a_token, a_secret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=["萌"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment