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

/Books/>: HTTP status code is not handled or not allowed
2017-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.也就是不遵守它的规则。

你可能感兴趣的:(python爬虫)