Update httperror.py

Log ignored HTTP pages when the response code is not allowed or not configured to be handled.
This commit is contained in:
deed02392 2014-02-24 15:55:04 +00:00
parent 822adb1d5f
commit 341c596232
1 changed files with 4 additions and 1 deletions

View File

@ -4,7 +4,7 @@ HttpError Spider Middleware
See documentation in docs/topics/spider-middleware.rst
"""
from scrapy.exceptions import IgnoreRequest
from scrapy import log
class HttpError(IgnoreRequest):
"""A non-200 response was filtered"""
@ -38,6 +38,9 @@ class HttpErrorMiddleware(object):
allowed_statuses = getattr(spider, 'handle_httpstatus_list', self.handle_httpstatus_list)
if response.status in allowed_statuses:
return
log.msg(format="Ignoring HTTP response code: not handled or not allowed: %(status_code)d",
level=log.DEBUG, spider=spider,
status_code=response.status)
raise HttpError(response, 'Ignoring non-200 response')
def process_spider_exception(self, response, exception, spider):