admin管理员组

文章数量:1619183

问题:
[scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (302)
(failed 3 times): [<twisted.python.failure.Failure twisted.web._newclient.ParseError: (‘wrong number of parts’, b’’)>]

理论知识:
1、在使用Scrapy框架中URl被重定向
2、根据 HTTP标准 ,返回值为200-300之间的值为成功的resonse。
3、如果想处理在这个范围之外的response,可以通过 spider的 handle_httpstatus_list 属性或HTTPERROR_ALLOWED_CODES 设置来指定spider能处理的response返回值。

解决1:
在爬虫文件的 settings.py文件里添加:

HTTPERROR_ALLOWED_CODES = [301]

解决2:
在爬虫文件中添加headers
该headers要添加自己的值,且cookie添加前,要先登录一下爬取的网站。
bibi为例,我已经登录成功了 F12–》Network --》刷新—》Header

herders={
	'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Ge

本文标签: twistedPythontimesscrapyfailed