Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get number of followers with Tweepy (no pagination)?

Tags:

tweepy

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.

like image 721
Mc- Avatar asked Aug 05 '12 17:08

Mc-


People also ask

How do I find out how many followers I have on Tweepy?

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.

How many tweets can you get with Tweepy?

Tweepy provides the convenient Cursor interface to iterate through different types of objects. Twitter allows a maximum of 3200 tweets for extraction.

How can I get more than 100 tweets on Tweepy?

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).

What is Tweepy rate limit?

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.


1 Answers

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

like image 147
Sam Avatar answered Oct 11 '22 14:10

Sam