我正在使用抓取蜘蛛来废弃https://www.walmart.com/browse/makeup/lips/1085666_1007040_1001527上的产品信息。 这就是我的规则。
rules = (Rule(LinkExtractor(
restrict_xpaths=('//*[@id="mainSearchContent"]/div[3]/div[2]/button[2]',)
),
callback = 'parse_page',
follow =True),)
这就是结果。它不会废弃任何东西。
017-07-05 13:32:33 [scrapy] INFO: Enabled item pipelines: ImagesPipeline
2017-07-05 13:32:33 [scrapy] INFO: Spider opened
2017-07-05 13:32:33 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2017-07-05 13:32:33 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6026
2017-07-05 13:32:35 [scrapy] DEBUG: Crawled (200) <GET https://www.walmart.com/browse/makeup/lips/1085666_1007040_1001527> (referer: None)
2017-07-05 13:32:35 [scrapy] INFO: Closing spider (finished)
2017-07-05 13:32:35 [scrapy] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 322,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 157281,
'downloader/response_count': 1,
'downloader/response_status_count/200': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 7, 5, 10, 32, 35, 320638),
'log_count/DEBUG': 2,
'log_count/INFO': 7,
'log_count/WARNING': 6,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2017, 7, 5, 10, 32, 33, 900621)}
如果我将回调更改为解析,它只会废弃第一页。 谁能告诉我如何废弃所有页面?
答案 0 :(得分:0)
这不能解决您的问题。但有一种从该网站获取数据的简便方法。只需要their API
这应该是评论,但网址太长,无法发表评论。
答案 1 :(得分:0)
您的'回调'应该是方法名称,而不是字符串。