Iteration des pages suivantes fonctionnelle
parent
557c76c2ca
commit
ec40af2cce
|
|
@ -22,7 +22,12 @@ class GetEpisodesSpider(scrapy.Spider):
|
||||||
def parse(self, response):
|
def parse(self, response):
|
||||||
for sel in response.xpath('//section[@class="emission-diffusions-list"]//a[@class="preview-list-element-link"]/@href'):
|
for sel in response.xpath('//section[@class="emission-diffusions-list"]//a[@class="preview-list-element-link"]/@href'):
|
||||||
url_episode = response.urljoin(sel.extract())
|
url_episode = response.urljoin(sel.extract())
|
||||||
|
next_page = response.xpath('//link[@rel="next"]/@href')
|
||||||
yield scrapy.Request(url_episode, callback = self.parse_episode)
|
yield scrapy.Request(url_episode, callback = self.parse_episode)
|
||||||
|
if next_page:
|
||||||
|
next_url = response.urljoin(next_page.extract_first())
|
||||||
|
yield scrapy.Request(url=next_url)
|
||||||
|
|
||||||
|
|
||||||
def parse_episode(self, response):
|
def parse_episode(self, response):
|
||||||
page_episode = scrapy.Selector(response)
|
page_episode = scrapy.Selector(response)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue