简体   繁体   中英

How to successfully get all the tweets for one user with 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM