我有一个spper刮掉页面并获取所有网址。
我有另一个spiner,它上面有一个网址和废料。
我想为第一个spiner的每个链接调用第二个spiner。
从第一个spiner获取所有链接的代码
for site in sites:
Link = site.xpath('a/@href').extract()
但我不知道如何为每个Link
请帮助
答案 0 :(得分:1)
我想你最好联合两只蜘蛛并做一些事情:
def get_links(self, response):
for site in sites:
link = site.xpath('a/@href').extract()[0]
yield Request(url=link, callback=self.scrape_them)
def scrape_them(self, response):
# by now scrapy called the link and you get the response
...