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

我们两清 提交于 2020-06-14 08:12:51

问题


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.


回答1:


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




回答2:


Try my solutions for count followers https://gist.github.com/3879338 In this code you need paste your data like consumer_key, consumer_secret, access_key, access_secret.



来源:https://stackoverflow.com/questions/11818638/how-to-get-number-of-followers-with-tweepy-no-pagination

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!