在Scrapy中更改响应URL

时间:2018-08-01 06:37:33

标签: scrapy

我使用以下代码遍历网站的页面。我向start_urls添加了一个网址。它调用parse()函数来更改response.css()所引用的网站。是否可以在不调用parse()函数的情况下进行更改?谢谢

def parse(self, response):

        next_url = self.website + response.css("div.results-paging__next a::attr(href)").extract_first()

        self.file.write(next_url + "\n")

        yield scrapy.Request(url = next_url, callback = self.parse)

0 个答案:

没有答案