我已经运行了一个蜘蛛并得到416错误,其中包含以下日志。请问,任何人都可以帮我弄清问题是什么?
2017-09-15 17:05:45 [scrapy] INFO: Scrapy 1.0.3 started (bot: apa)
2017-09-15 17:05:45 [scrapy] INFO: Optional features available: ssl, http11, boto
2017-09-15 17:05:45 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'apa.spiders', 'FEED_FORMAT': 'xml', 'SPIDER_MODULES': ['apa.spiders'], 'FEED_URI': 'testex.xml', 'BOT_NAME': 'apa'}
2017-09-15 17:05:45 [scrapy] INFO: Enabled extensions: CloseSpider, FeedExporter, TelnetConsole, LogStats, CoreStats, SpiderState
2017-09-15 17:05:45 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2017-09-15 17:05:45 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, ``UrlLengthMiddleware, DepthMiddleware
2017-09-15 17:05:45 [scrapy] INFO: Enabled item pipelines:
2017-09-15 17:05:45 [scrapy] INFO: Spider opened
2017-09-15 17:05:45 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2017-09-15 17:05:45 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-09-15 17:05:46 [scrapy] DEBUG: Crawled (416) <GET http://www.apa.org/research/action/aging.aspx> (referer: None)
2017-09-15 17:05:46 [scrapy] DEBUG: Ignoring response <416 http://www.apa.org/research/action/aging.aspx>: HTTP status code is not handled or not allowed
2017-09-15 17:05:46 [scrapy] INFO: Closing spider (finished)
2017-09-15 17:05:46 [scrapy] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 188,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 1857,
'downloader/response_count': 1,
'downloader/response_status_count/416': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 9, 15, 11, 35, 46, 706598),
'log_count/DEBUG': 3,
'log_count/INFO': 7,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2017, 9, 15, 11, 35, 45, 987587)}
2017-09-15 17:05:46 [scrapy] INFO: Spider closed (finished)
答案 0 :(得分:0)
您可以使用此
class ApaSpider(CrawlSpider):
handle_httpstatus_list = [416]
在请求 中的元中设置或
meta = {'handle_httpstatus_list': [416]}