gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 02:32:35 24 4
gpt4 key购买 nike

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

我的代码片段是

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

谢谢

最佳答案

您无需获取所有用户关注者即可统计他们。使用 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

打印:

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

希望对您有所帮助。

关于python - Twitter API - 获取关注者的关注者数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17450952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com