5

我正在使用此功能从 id 获取所有关注者:

def getAllFollowers(id):
    followers = tweepy.Cursor(api.followers, id = id)
    temp = []
    for user in followers.items():
        temp.append(user)

    return temp

有没有办法在不分页的情况下获得关注者、朋友、推文等的数量?只有号码。

4

3 回答 3

6

用户对象具有followers_count,friends_countstatuses_count这些属性。请参阅 Twitter API 文档中的示例响应:https ://dev.twitter.com/overview/api/users

此帐户当前拥有的关注者数量。在某些胁迫条件下,该字段将暂时显示“0”。例子:

"followers_count": 21

于 2012-08-06T20:15:17.890 回答
4

试试我的追随者计数解决方案 https://gist.github.com/3879338 在此代码中,您需要粘贴您的数据,例如 consumer_key、c​​onsumer_secret、access_key、access_secret。

于 2013-01-04T10:42:26.377 回答
0

使用用户对象中的“followers_count”:

handle = 'justinbieber'

user = api.get_user(handle)
num_followers = user.followers_count
num_friends = user.friends_count
于 2021-01-12T14:49:08.517 回答