Compare commits
2 Commits
f33eda3ff1
...
ec40af2cce
| Author | SHA1 | Date |
|---|---|---|
|
|
ec40af2cce | |
|
|
557c76c2ca |
|
|
@ -20,9 +20,14 @@ class GetEpisodesSpider(scrapy.Spider):
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse(self, response):
|
def parse(self, response):
|
||||||
for sel in response.xpath('//section[@class="emission-diffusions-list"]'):
|
for sel in response.xpath('//section[@class="emission-diffusions-list"]//a[@class="preview-list-element-link"]/@href'):
|
||||||
url_episode = response.urljoin(sel.xpath('.//a[@class="preview-list-element-link"]/@href').extract_first())
|
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)
|
||||||
|
|
@ -33,4 +38,6 @@ class GetEpisodesSpider(scrapy.Spider):
|
||||||
for field, xpath in self.episode_fields.items():
|
for field, xpath in self.episode_fields.items():
|
||||||
loader.add_xpath(field, xpath)
|
loader.add_xpath(field, xpath)
|
||||||
|
|
||||||
|
loader.add_value('url_page', response.url)
|
||||||
|
|
||||||
yield loader.load_item()
|
yield loader.load_item()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue