Tweepy 不处理 429 HTTP 错误(请求过多)
Tweepy does not handle 429 HTTP error (Too many Requests)
我目前正在使用 Tweepy 库,几天前我就启动了它。然而过了一段时间,我在收集到的每条推文之间收到以下消息:
HTTP Error 429: Too Many Requests
或
Service not available
我认为在处理这种事情时将函数 wait_on_rate_limit
设置为 True,或者它可能没有考虑到 429 错误?我刚刚在我的过滤器中请求了大约 10 个术语,returns 每 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 了解更多信息
我目前正在使用 Tweepy 库,几天前我就启动了它。然而过了一段时间,我在收集到的每条推文之间收到以下消息:
HTTP Error 429: Too Many Requests
或
Service not available
我认为在处理这种事情时将函数 wait_on_rate_limit
设置为 True,或者它可能没有考虑到 429 错误?我刚刚在我的过滤器中请求了大约 10 个术语,returns 每 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 了解更多信息