HTTP status code is not handled or not allowed的解决方法

来源:互联网 发布:无忧商务推广软件 编辑:程序博客网 时间:2024/06/07 10:06
/Books/>: HTTP status code is not handled or not allowed2017-11-04 17:21:38 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response <403 http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/>: HTTP status code is not handled or not allowed

我遇到的这个问题出现在scrapy里面,解决办法是在settings里面添加

HTTPERROR_ALLOWED_CODES = [403]#上面报的是403,就把403加入。

彩蛋:

scrapy默认是遵守爬虫准则的,即settings里面,ROBOTSTXT_OBEY = True。
比如抓取百度,在https://www.baidu.com/robots.txt里,有这样的一个规范。如果遵守,比如今日头条,是不能用scrapy爬取的。这个时候需要把ROBOTSTXT_OBEY=False.也就是不遵守它的规则。

阅读全文
0 0
原创粉丝点击