Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json, pygame, pickle, sys, os
- from tweepy.streaming import StreamListener
- from tweepy import OAuthHandler
- from tweepy import Stream
- global i
- i = 0
- consumer_key="YOURS_HERE"
- consumer_secret="YOURS_HERE"
- access_token="YOURS_HERE"
- access_token_secret="YOURS_HERE"
- class StdOutListener(StreamListener):
- """
- """
- def on_data(self, data):
- global i
- json_data = json.loads(data)
- msg = "Creating: " + json_data['user']['screen_name'].encode('utf-8')
- try:
- # YOUR CODE HERE
- print "created:", tweet
- print i
- i = i+1
- except Exception, err:
- print err
- def on_error(self, status):
- if status == 420:
- print "Enhance your calm", 'http://en.wikipedia.org/wiki/List_of_HTTP_status_codes'
- print "Error:", status
- if __name__ == '__main__':
- print "Starting..."
- l = StdOutListener()
- print "Authenticating..."
- auth = OAuthHandler(consumer_key, consumer_secret)
- auth.set_access_token(access_token, access_token_secret)
- print "Connecting..."
- stream = Stream(auth, l)
- #clean_up?
- print "Listening..."
- stream.filter(track=[ '#google' ], languages=["en"])
Add Comment
Please, Sign In to add comment