Last active
October 20, 2016 15:17
-
-
Save Adagio-cantabile/cb39c9ec69c84fac0c7618ab7f4d87dc to your computer and use it in GitHub Desktop.
streaming with tweepy
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 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