debug:403,是不是就不允许爬了,怎么办?
执行
class FoodSpiderSpider(scrapy.Spider): name = 'food_spider' allowed_domains = ['www.xiangha.com'] start_urls = ['https://www.xiangha.com/shicai/s-roulei'] def parse(self, response): print(response.text)
图片
全部返回结果
(base) C:\Users\wt271\AnacondaProjects\scrapy_one>scrapy crawl food_spider
:0: UserWarning: You do not have a working installation of the service_identity module: 'cannot import name 'opentype''. Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
2018-07-15 17:10:01 [scrapy.utils.log] INFO: Scrapy 1.5.1 started (bot: scrapy_one)
2018-07-15 17:10:01 [scrapy.utils.log] INFO: Versions: lxml 3.7.2.0, libxml2 2.9.4, cssselect 1.0.3, parsel 1.5.0, w3lib 1.19.0, Twisted 18.7.0, Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)], pyOpenSSL 16.2.0 (OpenSSL 1.0.2k 26 Jan 2017), cryptography 1.7.1, Platform Windows-10-10.0.17134-SP0
2018-07-15 17:10:01 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'scrapy_one', 'DOWNLOAD_DELAY': 0.5, 'NEWSPIDER_MODULE': 'scrapy_one.spiders', 'ROBOTSTXT_OBEY': True, 'SPIDER_MODULES': ['scrapy_one.spiders']}
2018-07-15 17:10:02 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.logstats.LogStats']
2018-07-15 17:10:05 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware',
'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
'scrapy.downloadermiddlewares.retry.RetryMiddleware',
'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
'scrapy.downloadermiddlewares.stats.DownloaderStats']
2018-07-15 17:10:05 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
2018-07-15 17:10:05 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2018-07-15 17:10:05 [scrapy.core.engine] INFO: Spider opened
2018-07-15 17:10:05 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2018-07-15 17:10:05 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2018-07-15 17:10:06 [scrapy.core.downloader.tls] WARNING: Remote certificate is not valid for hostname "www.xiangha.com"; '*.xiangha.com'!='www.xiangha.com'
2018-07-15 17:10:06 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.xiangha.com/robots.txt> (referer: None)
2018-07-15 17:10:06 [scrapy.core.engine] DEBUG: Crawled (403) <GET https://www.xiangha.com/shicai/s-roulei> (referer: None)
2018-07-15 17:10:06 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response <403 https://www.xiangha.com/shicai/s-roulei>: HTTP status code is not handled or not allowed
2018-07-15 17:10:06 [scrapy.core.engine] INFO: Closing spider (finished)
2018-07-15 17:10:06 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 453,
'downloader/request_count': 2,
'downloader/request_method_count/GET': 2,
'downloader/response_bytes': 759,
'downloader/response_count': 2,
'downloader/response_status_count/200': 1,
'downloader/response_status_count/403': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 7, 15, 9, 10, 6, 485799),
'httperror/response_ignored_count': 1,
'httperror/response_ignored_status_count/403': 1,
'log_count/DEBUG': 3,
'log_count/INFO': 8,
'log_count/WARNING': 1,
'response_received_count': 2,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2018, 7, 15, 9, 10, 5, 526006)}
2018-07-15 17:10:06 [scrapy.core.engine] INFO: Spider closed (finished)