Skip to content

Instantly share code, notes, and snippets.

@fitzk

fitzk/trump_tweets.py

Last active Feb 8, 2017
Embed
What would you like to do?
Generates a JSON object of Donald Trump's tweets and their associated meta-data.
import tweepy
import json
CONSUMER_KEY = # your consumer key
CONSUMER_SECRET = # your consumer secret
ACCESS_KEY = # your access key
ACCESS_SECRET = # your access secret
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
# Redirect user to Twitter to authorize
# Construct the API instance
api = tweepy.API(auth)
json_arr = [item._json for item in tweepy.Cursor(api.user_timeline, id="realDonaldTrump").items()]
print(json.dumps(json_arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.