我正在尝试为我的帐户建立一个追随者列表。最终的目标是自动跟踪任何新的追随者。看看其他的实现,我猜最好的方法是先编译一个当前关注者的列表,然后偶尔编译一个新的列表,做一个列表比较,然后为任何新的用户id启动follow命令。你知道吗
然而,我管理的帐户有几千个追随者,目前我收到约300个项目之前,每个要求率限制器启动。其他文件暗示,这可能是每个请求5000,那么我做错了什么?我怎样才能收到5000英镑?(或者有没有其他方法可以简单地跟踪新的追随者?)。你知道吗
auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY,ACCESS_SECRET)
api = tweepy.API(auth,wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
now = datetime.now()
now_time = now.time()
print ('Limit Reached - Resuming at {}'.format(now + timedelta(minutes=20)))
sleep(20 * 60)
def follow_gen():
for user in limit_handled(tweepy.Cursor(api.followers, count=5000).items()):
with open('follower_list2.txt','a') as f:
f.write('{}-{}\n'.format(user.id, user.screen_name))
follow_gen()
我也尝试了.pages()
而不是.items()
,但是我仍然似乎每个请求只能得到大约300个id。你知道吗
我的愚蠢举动-解决了。你知道吗
api.followers
受Tweepy限制,每个调用只能有100个响应。使用api.followers_ids
它就像做梦一样工作。你知道吗相关问题 更多 >
编程相关推荐