简体   繁体   English

Twitter随机速率限制

[英]Twitter Random Rate Limiting

I am trying to retrieve user Friend network using python-twitter API. 我正在尝试使用python-twitter API检索用户Friend网络。 I am using the getFriendIDs() method which retrieves the ids of all the accounts a particular twitter user is following. 我正在使用getFriendIDs()方法,该方法检索特定Twitter用户正在关注的所有帐户的ID。 The following is a small snipped of my test code: 以下是我的测试代码的小片段:

for item in IdList:
    aDict[item] = api.GetFriendIDs(user_id=item,count=4999)
    print "sleeping 60"
    time.sleep(66)
    print str(api.MaximumHitFrequency())+" The maximum hit frequency"
    print api.GetRateLimitStatus()['resources']['friends']['/friends/ids']['remaining']

There are 35 ids (of twitter user accounts) in IdList and for each item I am retrieving upto 4999 Ids that the current user with id 'item' is following. IdList中有35个(Twitter用户帐户的)ID,对于每个项目,我最多检索到ID为'item'的当前用户所关注的4999个ID。 I am aware of the new rate-limiting by twitter wherein the rate-limit window has been changed from 60 minutes to 15 minutes and the fact that they advice you not to make more than one request to the server per minute (api.MaximumHitFrequency()). 我知道Twitter的新速率限制,其中速率限制窗口已从60分钟更改为15分钟,并且他们建议您每分钟不要对服务器发出一个以上请求(api.MaximumHitFrequency( ))。 So basically 15 requests in 15 minutes. 因此,基本上在15分钟内有15个请求。 That is exactly what I'm doing in fact I'm making a request to the server every 66 seconds and not 60 seconds but I get a rate-limit error after 6 requests. 实际上,这就是我正在执行的操作,实际上是每66秒而不是60秒向服务器发出一次请求,但是在6次请求后出现了限速错误。 I am unable to figure out why this is happening. 我无法弄清楚为什么会这样。 Please do let me know if anyone else has had this problem. 请让我知道是否有人遇到此问题。

Have a look at https://github.com/bear/python-twitter/wiki/Rate-Limited-API---How-to-deal-with . 看看https://github.com/bear/python-twitter/wiki/Rate-Limited-API---How-to-deal-with

Also, it might help to use a newer version of the python-twitter code. 另外,使用更新版本的python-twitter代码可能会有所帮助。 The MaximumHitFrequency and GetRateLimitStatus methods have been modified with https://github.com/bear/python-twitter/commit/25cccb81fbeb4c630a0024981bc98f7fb41f3933 . MaximumHitFrequency和GetRateLimitStatus方法已通过https://github.com/bear/python-twitter/commit/25cccb81fbeb4c630a0024981bc98f7fb41f3933进行了修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM