admin管理员组文章数量:1618733
问题:
[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
版权声明:本文标题:scrapy--(failed 3 times): [<twisted.python.failure.Failure twisted.web._newclient.ParseError 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728785088a1173225.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论