问题描述
我正在尝试获取特定帐户的每个关注者的关注者数量(目标是找到最具影响力的关注者).我在 Python 中使用 Tweepy,但我遇到了 API 速率限制,并且在我被切断之前我只能获得 5 个关注者的关注者数量.我正在查看的帐户有大约 2000 名关注者.有什么办法可以解决这个问题吗?
I'm trying to get the number of followers of each follower for a specific account (with the goal of finding the most influencial followers). I'm using Tweepy in Python but I am running into the API rate limits and I can only get the number of followers for 5 followers before I am cut off. The account I'm looking at has about 2000 followers. Is there any way to get around this?
我的代码片段是
ids = api.followers_ids(account_name)
for id in ids:
more = api.followers_ids(id)
print len(more)
谢谢
推荐答案
您无需获取所有用户关注者即可对其进行计数.使用 followers_count
属性.例如:
You don't need to get all user followers in order to count them. Use followers_count
property. E.g.:
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
...
希望有所帮助.
这篇关于Twitter API - 获取关注者的关注者数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!