tweepy (python):超出速率限制代码 88 [英] tweepy (python): rate limit exceeded code 88
问题描述
我正在用 tweepy 编写一个 Twitter 应用程序,它通过查看 in_reply_to_status_ID 来爬取推文.一切正常,直到速率限制,几分钟后,我必须再等 15 分钟左右.
I'm writing a Twitter application with tweepy that crawls up the tweets by looking at in_reply_to_status_ID. Everything works fine up to the rate limit, after a few minutes, I have to wait another 15 minutes or so.
这很奇怪,因为直到几个月前 API 1.0 被弃用之前我使用了几乎相同的代码,而且它没有速率限制问题.
This is strange because I used nearly identical code until a few months ago before API 1.0 got deprecated, and it didn't have the rate limit problem.
有没有已知的方法可以摆脱或至少增加速率限制?或者有解决方法吗?
Is there a known way I can get rid of, or at least increase the rate limit? Or is there a workaround?
似乎很多人都遇到了这个问题,但找不到明确的解决方案..
Seems like a lot of people are having trouble with this, but can't find a definite solution..
如果您能提供帮助,我将不胜感激.
i will greatly appreciate it if you could help.
auth1 = tweepy.auth.OAuthHandler('consumer_token','consumer_secret')
auth1.set_access_token('access_token','access_secret')
api=tweepy.API(auth1)
def hasParent(s):
#return true if s is not None, i.e., s is an in_reply_to_status_id numbe
....
while hasParent(ps):
try:
parent=api.get_status(ps)
except tweepy.error.TweepError:
print 'tweeperror'
break
newparent = parent.in_reply_to_status_id
......
ps=newparent
推荐答案
我设置了一个限制并且工作了:
I put a limit and worked:
def index(request):
statuses = tweepy.Cursor(api.user_timeline).items(10)
return TemplateResponse(request, 'index.html', {'statuses': statuses})
这篇关于tweepy (python):超出速率限制代码 88的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!