凌乱的亚马逊页面前几页

  • 本文关键字:几页 亚马逊 scrapy
  • 更新时间 :
  • 英文 :


目前在Amazon data scraper中使用Scrapy进行分页,我使用

next_page = response.xpath('//li[@class="a-last"]/a/@href').get()
if next_page:
next_page = 'https://www.amazon.com' + next_page
yield scrapy.Request(url=next_page,callback=self.parse,headers=self.amazon_header,dont_filter=True)

如果我只想从前3页获取数据,我该怎么做?

进入settings.py文件,按如下方式限制分页:

CLOSESPIDER_PAGECOUNT = 3

选择:假设,Url =['https://www.quote.toscrape/page=1 something']

现在在start_urls中以这种方式进行分页,并排除next分页

start_urls =[ '​https:// www.quote.toscrape/page='+str(x)+' something' for x in range(1,3)]

最新更新