繁体   English   中英

Tweepy无法处理429 HTTP错误(请求过多)

[英]Tweepy does not handle 429 HTTP error (Too many Requests)

我目前正在使用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

嗨!

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

暂无
暂无

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

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