我想从多个网址抓取信息。我使用下面的代码,但它不工作。有人能告诉我哪里出了问题吗?你知道吗
import scrapy
class spider1(scrapy.Spider):
name = "spider1"
domain = "http://www.amazon.com/dp/"
ASIN = ['B01LA6171I', 'B00OUKHTLO', 'B00B7LUVZK']
def start_request(self):
for i in ASIN:
yield scrapy.Request(url=domain+i, callback=self.parse)
def parse(self, response):
title = response.css("span#productTitle::text").extract_first().strip()
ASIN_ext = response.xpath("//input[@name='ASIN']/@value").extract_first()
data = {"ASIN": ASIN_ext, "title": title, }
yield data
方法名中有一个输入错误:它应该是
start_requests
,而不是start_request
。你知道吗相关问题 更多 >
编程相关推荐