Twitter API - 获取关注者的关注者数量

2024-05-16

我试图获取特定帐户的每个关注者的关注者数量(目标是找到最有影响力的关注者)。我在 Python 中使用 Tweepy,但遇到了 API 速率限制,在被切断之前我只能获取 5 个关注者的关注者数量。我正在查看的帐户大约有 2000 名关注者。有什么办法可以解决这个问题吗?

我的代码片段是

ids = api.followers_ids(account_name)
for id in ids:
    more = api.followers_ids(id)
    print len(more)

Thanks


您无需获取所有用户关注者即可对其进行计数。使用followers_count财产。例如。:

import tweepy

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

api = tweepy.API(auth)

for user in tweepy.Cursor(api.followers, screen_name="twitter").items():
    print user.screen_name, user.followers_count

Prints:

...
pizzerialoso 0
Mario98Y 0
sumankumarjana 1
realattorneylaw 3056
JaluSeptyan 10
andhita_khanza 18
...

希望有帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Twitter API - 获取关注者的关注者数量 的相关文章

随机推荐