Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to successfully get all the tweets for one user with tweepy?

Tags:

python

tweepy

I am trying to pull all the tweets from USATODAY's twitter account. But, I keep hitting the rate limits when doing so. How do I start from where I left off of after I hit the rate limit?

For example, there are a total of 100k tweets. My code gets the first 3000 then hits the limit. How do I start at 3001 when my limit resets and so on until I can get all 100k?

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)

api = tweepy.API(auth)

for tweet in tweepy.Cursor(api.user_timeline,id='USATODAY').items():
    print(tweet)
like image 544
collarblind Avatar asked May 20 '15 20:05

collarblind


1 Answers

Outside of API limits, only the most recent 3000 tweets are available to anyone other than the account holder, even in the web interface. If you want the tweets before that, you'd need access to the archive.

like image 130
manglano Avatar answered Nov 14 '22 23:11

manglano