Skip to content

Instantly share code, notes, and snippets.

@jaimezorno
Last active August 3, 2019 13:10
Show Gist options
  • Save jaimezorno/1f3655fafbc55055f381a3faa10d377e to your computer and use it in GitHub Desktop.
Save jaimezorno/1f3655fafbc55055f381a3faa10d377e to your computer and use it in GitHub Desktop.
Initial Twitter Downloader
#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
# Enter Twitter API Keys
access_token = "ENTER ACCESS TOKEN"
access_token_secret = "ENTER ACCESS TOKEN SECRET"
consumer_key = "ENTER CONSUMER KEY"
consumer_secret = "ENTER CONSUMER SECRET"
# Create the class that will handle the tweet stream
class StdOutListener(StreamListener):
def on_data(self, data):
print(data)
return True
def on_error(self, status):
print(status)
if __name__ == '__main__':
# Handle Twitter authetification and the connection to Twitter Streaming API
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)
stream.filter(track=tracklist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment