Get All Follower IDs in Twitter by Tweepy

In order to avoid rate limit, you can/should wait before the next follower page request. Looks hacky, but works:

import time
import tweepy

auth = tweepy.OAuthHandler(..., ...)
auth.set_access_token(..., ...)

api = tweepy.API(auth)

ids = []
for page in tweepy.Cursor(api.followers_ids, screen_name="McDonalds").pages():
    ids.extend(page)
    time.sleep(60)

print len(ids)

Hope that helps.

Leave a Comment

tech