【问题标题】:Tweepy does not handle 429 HTTP error (Too many Requests)Tweepy 不处理 429 HTTP 错误(请求过多)
【发布时间】:2018-09-28 16:40:04
【问题描述】:

我目前正在使用 Tweepy 库,并且从几天前就启动了它。但是过了一会儿,我在收集的每条推文之间收到了以下消息:

HTTP 错误 429:请求过多

或者

服务不可用

我认为在处理这种事情时将函数wait_on_rate_limit设置为True,或者它没有考虑429错误?我刚刚在我的过滤器中请求了大约 10 个术语,最多每 5-10 秒返回大约 1 条推文。

我该如何处理这类问题?顺便说一句,有我的一段代码:

streamer = tweepy.Stream(auth=api.auth, listener=StreamListener(), timeout=3000000000)
streamer.filter(None,terms)

class StreamListener(tweepy.StreamListener):
    status_wrapper = TextWrapper(width=60, initial_indent='    ', subsequent_indent='    ')

def on_status(self, status):
    print ('{} {} - {}'.format(status.author.screen_name, status.created_at,status.text))
    saveTweet(status)
def on_disconnect(self, notice):
    print ("Disconnect: {}".format(notice))
    return

def on_warning(self, notice):
    print ("Warning: {}".format(notice))
    return

def on_exception(self, exception):
    print ("Exception: ".format(exception))
    return
def on_error(self, status_code):
    if (status_code == 403):
         print("Limit probably reached")
    else:
         print("Error occured > {}".format(status_code))
    return False

【问题讨论】:

  • 我现在在收集的推文之间也有以下消息Service not available

标签: python twitter tweepy http-status-code-429


【解决方案1】:

嗨!

对于那些有同样问题的人,只需升级 Tweepy !我在 Github 的 Tweepy 项目上提出了一个问题,已经解决。请参阅问题#791 了解更多信息

【讨论】:

    猜你喜欢
    • 2020-05-26
    • 1970-01-01
    • 2020-04-24
    • 2014-05-12
    • 2019-10-04
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多