I'm using this function to get all followers from an id:
def getAllFollowers(id):
followers = tweepy.Cursor(api.followers, id = id)
temp = []
for user in followers.items():
temp.append(user)
return temp
Is there a way to get the number of followers, or friends, tweets, etc... without pagination?? Only the number.
In order to get the number of followers we have to do the following : Identify the user ID or the screen name of the profile. Get the User object of the profile using the get_user() method with the user ID or the screen name. From this object, fetch the followers_count attribute present in it.
Tweepy provides the convenient Cursor interface to iterate through different types of objects. Twitter allows a maximum of 3200 tweets for extraction.
If you need more than 100 Tweets, you have to use the paginator method and specify the limit i.e. the total number of Tweets that you want. Replace limit=1000 with the maximum number of tweets you want. Replace the limit=1000 with the maximum number of tweets you want (gist).
But keep in mind that Twitter levies a rate limit on the number of requests made to the Twitter API. To be precise, 900 requests/15 minutes are allowed; Twitter feeds anything above that an error.
User objects have followers_count
, friends_count
and statuses_count
attributes for these. See the example response in the Twitter API docs: https://dev.twitter.com/overview/api/users
The number of followers this account currently has. Under certain conditions of duress, this field will temporarily indicate “0”. Example:
"followers_count": 21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With