我想凑使用Tweepy一些微博,但有以下错误几百请求后,连接崩溃: tweepy.error.TweepError: 无法发送请求:('连接异常中止。 ”,错误( “(104, 'ECONNRESET')”,))Tweepy错误104:连接异常中止
我的代码是这样的:
for status in tweepy.Cursor(api.search,
q="",
count=100,
include_entities=True,
monitor_rate_limit=True,
wait_on_rate_limit=True,
wait_on_rate_limit_notify = True,
retry_count = 5, #retry 5 times
retry_delay = 5, #seconds to wait for retry
geocode ="34.0207489,-118.6926066,100mi", # los angeles
until=until_date,
lang="en").items():
try:
towrite = json.dumps(status._json)
output.write(towrite + "\n")
except Exception, e:
log.error(e)
c+=1
if c % 10000 == 0: # 100 requests, sleep
time.sleep(900) # sleep 15 min
我可以尝试/捕获错误除外,但我不能重启光标从它坠毁的地方开始。 有谁知道如何解决这个错误,或重新从最后一个已知的状态光标?
谢谢!