当构建蜘蛛时遇到了一件有趣的事情 - 您需要将对该函数的引用传递给它,然后在Selector中发送。尝试过所有可用的响应和请求方法Scrapy,但数据不会来。Scrapy。在选择器中发送链接
一段代码就明白了:
start_urls = [
"http://www.site.ru/"
]
def parse(self, response):
sel = Selector(response)
self.links = sel.xpath('//*[@id="col-01"]/div/div/ul/li/a/@href').extract()
def parse_catalog(self, response):
sel = Selector(response)
elements = sel.xpath('//*[@id="col-01"]/div[1]/ul[1]/
li[4]/div[2]/strong/text()').extract()[0]
links_auto = sel.xpath('//div[@class="car-detail-list"]/a/@href').extract()
for link in links_auto:
self.parse_page(link)
def parse_page(self, link):
response = ??? (link)
self.sel = Selector(response)
你想达到什么目的? – Martol1ni