Skip to content

Instantly share code, notes, and snippets.

@fitzk
Last active February 8, 2017 22:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitzk/782f7a01d6927b0ccf6e7d2efcaa3cc5 to your computer and use it in GitHub Desktop.
Save fitzk/782f7a01d6927b0ccf6e7d2efcaa3cc5 to your computer and use it in GitHub Desktop.
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