Skip to content

Instantly share code, notes, and snippets.

@thiagodeschamps
Forked from yanofsky/LICENSE
Last active December 20, 2018 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagodeschamps/6cb699a4aec017145a0276ccfcae51c3 to your computer and use it in GitHub Desktop.
Save thiagodeschamps/6cb699a4aec017145a0276ccfcae51c3 to your computer and use it in GitHub Desktop.
A script to download all of a user's tweets into a text file
import tweepy
def get_all_tweets(screen_name):
auth = tweepy.OAuthHandler('---------------------', '-----------------------------------------------')
auth.set_access_token('------------------------------------','--------------------------=--')
api = tweepy.API(auth)
alltweets = []
new_tweets = api.user_timeline(screen_name = screen_name,count=200, include_rts = False)
alltweets.extend(new_tweets)
oldest = alltweets[-1].id - 1
while len(new_tweets) > 0:
new_tweets = api.user_timeline(screen_name = screen_name,count=200,max_id=oldest, include_rts = False)
alltweets.extend(new_tweets)
oldest = alltweets[-1].id - 1
with open('tweets.txt', 'w') as f:
for c, i in enumerate(alltweets):
f.write(f'Criado em:{i.created_at}\n{c}: {i.text}\n\n\n')
get_all_tweets('youtube')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment