Created
June 6, 2014 03:07
-
-
Save bigsnarfdude/bd3f7b59e49d4c555bb0 to your computer and use it in GitHub Desktop.
HashTag Twitter Streamer
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
from tweepy import Stream | |
from tweepy import OAuthHandler | |
from tweepy.streaming import StreamListener | |
consumer_key = "HsYoJa0sdf980as8fbFh0w" | |
consumer_secret = "k698asdf9870sdf09a7s8df908a7sdf6A7m4" | |
access_token = "364asdf987asdfuiytsdaf765sdfasdfoiyLgS" | |
access_token_secret = "SFasdf9807asd09f87asf9087asdfbik5D" | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
class listener(StreamListener): | |
def on_status(self, status): | |
print 'Tweet text: ' + status.text | |
for hashtag in status.entries['hashtags']: | |
print hashtag['text'] | |
return True | |
def on_data(self, data): | |
print data | |
return True | |
def on_error(self, status): | |
print status | |
twitterStream = Stream(auth, listener()) | |
twitterStream.filter( track=["#iLoveBigData"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment