Last active
February 8, 2017 22:18
-
-
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.
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
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