Last active
October 27, 2018 15:50
-
-
Save cosmos-sajal/92779d2e5658e39e5eda366abc415663 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from tweepy import Stream | |
from tweepy import OAuthHandler | |
from tweepy import api | |
from tweepy.streaming import StreamListener | |
import json | |
#consumer key, consumer secret, access token, access secret. | |
ckey="<ckey>" | |
csecret="<csecret>" | |
atoken="<atoken>" | |
asecret="<asecret>" | |
class listener(StreamListener): | |
def on_data(self, data): | |
all_data = json.loads(data) | |
tweet = all_data["text"] | |
print(tweet) | |
def on_error(self, status): | |
print(status) | |
auth = OAuthHandler(ckey, csecret) | |
auth.set_access_token(atoken, asecret) | |
twitterStream = Stream(auth, listener()) | |
twitterStream.filter(track=["HillaryClinton"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment