【问题标题】:tweepy (python): rate limit exceeded code 88tweepy (python):速率限制超出代码 88
【发布时间】:2013-12-31 19:17:55
【问题描述】:

我正在使用 tweepy 编写一个 Twitter 应用程序,它通过查看 in_reply_to_status_ID 来抓取推文。 一切正常,达到速率限制,几分钟后,我必须再等 15 分钟左右。

这很奇怪,因为直到几个月前 API 1.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

【问题讨论】:

标签: python twitter tweepy


【解决方案1】:

我设置了一个限制并且工作了:

def index(request):
    statuses = tweepy.Cursor(api.user_timeline).items(10)
    return TemplateResponse(request, 'index.html', {'statuses': statuses})

【讨论】:

  • 感谢您的发帖!您能否解释一下您的答案背后的逻辑,以及它如何适用于我的案例?
【解决方案2】:

这是由于您达到了最大限制。只需断开您的互联网连接并重新连接,无需等待。 使用光标:

statuses = tweepy.Cursor(api.user_timeline).items(2)

如果你再次收到错误,只需减少项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 2015-10-20
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多