为了账号安全,请及时绑定邮箱和手机立即绑定

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)

图片

https://img1.sycdn.imooc.com//5b4b12800001e9c309670150.jpg

全部返回结果

(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)

正在回答

2 回答

输出信息里没有ua

0 回复 有任何疑惑可以回复我~
#1

无无法师 提问者

非常感谢!
2018-07-16 回复 有任何疑惑可以回复我~
#2

Scorpio丶小伟 回复 无无法师 提问者

...ua,什么意思呀,麻烦说一下。
2018-07-27 回复 有任何疑惑可以回复我~
#3

大壮老师 回复 Scorpio丶小伟

user-agent
2018-07-31 回复 有任何疑惑可以回复我~
#4

Scorpio丶小伟 回复 大壮老师

谢谢老师
2018-08-04 回复 有任何疑惑可以回复我~
#5

慕田峪3222305 回复 无无法师 提问者

想问一下楼主是怎么解决的,最近在学爬虫,我也遇到了这个问题
2019-08-19 回复 有任何疑惑可以回复我~
查看2条回复

想问一下楼主是怎么解决的,最近在学爬虫,我也遇到了这个问题

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

debug:403,是不是就不允许爬了,怎么办?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信