Scraping des liens et récupération des informations dans le même spider
parent
b27272d3a8
commit
b0f57b9a37
|
|
@ -4,10 +4,15 @@ import scrapy
|
||||||
|
|
||||||
class GrabvideodataSpider(scrapy.Spider):
|
class GrabvideodataSpider(scrapy.Spider):
|
||||||
name = 'grabVideoData'
|
name = 'grabVideoData'
|
||||||
allowed_domains = ['http://www.cinematheque.fr/']
|
allowed_domains = ['cinematheque.fr']
|
||||||
start_urls = ['http://www.cinematheque.fr/video/1219.html']
|
start_urls = ['http://www.cinematheque.fr/decouvrir.html']
|
||||||
|
|
||||||
def parse(self, response):
|
def parse(self, response):
|
||||||
|
for lien in response.xpath('//a/@href[contains(.,"video")]/../..'):
|
||||||
|
url = response.urljoin(lien.css('a::attr(href)').extract_first())
|
||||||
|
yield scrapy.Request(url, callback = self.parse_dir_content)
|
||||||
|
|
||||||
|
def parse_dir_content(self, response):
|
||||||
for page in response.css("div#content"):
|
for page in response.css("div#content"):
|
||||||
yield {
|
yield {
|
||||||
'titre' : page.css('h1::text').extract_first(),
|
'titre' : page.css('h1::text').extract_first(),
|
||||||
|
|
@ -17,4 +22,3 @@ class GrabvideodataSpider(scrapy.Spider):
|
||||||
'tags' : page.css('.tag::text').extract()
|
'tags' : page.css('.tag::text').extract()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import scrapy
|
|
||||||
|
|
||||||
|
|
||||||
class ListevideosSpider(scrapy.Spider):
|
|
||||||
name = 'listeVideos'
|
|
||||||
allowed_domains = ['http://www.cinematheque.fr/']
|
|
||||||
start_urls = ['http://www.cinematheque.fr/decouvrir.html']
|
|
||||||
|
|
||||||
def parse(self, response):
|
|
||||||
for lien in response.xpath('//a/@href[contains(.,"video")]/../..'):
|
|
||||||
yield {
|
|
||||||
'adresse' : lien.css('a::attr(href)').extract(),
|
|
||||||
'dateUpload' : lien.css('::attr(data-sort)').extract(),
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue