python - 请问scrapy中如何设置request的重试次数
天蓬老师
天蓬老师 2017-04-18 09:37:31
0
1
869

scrapy版本:1.1.2
python 版本:3.5

在使用scrapy抓取数据的时候使用了代理IP,难免会遇到代理IP失效的情况。

因为对数据完整性要求较高,请问如何设置只要没有成功的返回response则把任务重新放进Request队列中去继续爬取?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
阿神

You can use the one that comes with scrapyscrapy.downloadermiddlewares.retry.RetryMiddleware中间件,然后通过这几个参数进行配置:
RETRY_ENABLED: 是否开启retry
RETRY_TIMES: 重试次数
RETRY_HTTP_CODECS: You need to retry when you encounter any http code. The default is 500, 502, 503, 504, 408. Other problems such as network connection timeout will also be automatically retried

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!