我正在用tweepy编写一个tweepy应用程序,它通过查看in_reply_to_status_ID来爬过tweets。 一切正常到限速,几分钟后,我还要再等15分钟左右。在
这很奇怪,因为我使用了几乎相同的代码,直到几个月前,在api1.0被弃用之前,它没有速率限制问题。在
有没有什么办法可以让我摆脱,或者至少提高利率限制? 或者有解决办法吗?在
好像很多人都有这个问题,但找不到一个明确的解决办法。。在
如果你能帮忙,我将不胜感激。在
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
这是因为你达到了最大限度。只需断开网络连接,然后重新连接,无需等待。 使用光标:
statuses = tweepy.Cursor(api.user_timeline).items(2)
如果您再次出现错误,只需减少项目。在
我设定了一个限度,然后工作了:
相关问题 更多 >
编程相关推荐