CFVideoScraper/CinemScraper/items.py

54 lines
1.4 KiB
Python
Raw Normal View History

2018-05-10 17:31:59 +00:00
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html
import scrapy
from scrapy.loader.processors import Join, MapCompose, TakeFirst
2018-05-10 17:31:59 +00:00
def format_date(value):
month = {
'janvier' : '01',
'février' : '02',
'mars' : '03',
'avril' : '04',
'mai' : '05',
'juin' : '06',
'juillet' : '07',
'août' : '08',
'septembre' : '09',
'octobre' : '10',
'novembre' : '11',
'décembre' : '12'
}
date = value.split(' ')
yield date[0]+'-'+month[date[1]]+'-'+date[2]
def clean_text(value):
text = value.replace('\\n', '')
yield text.strip()
def clean_url(value):
yield value.split('?')[0]
2018-05-10 17:31:59 +00:00
2018-05-11 22:46:01 +00:00
class video(scrapy.Item):
title = scrapy.Field(
input_processor = MapCompose(clean_text),
output_processor = Join()
)
secondary_title = scrapy.Field()
2018-05-11 22:46:01 +00:00
description = scrapy.Field()
urlVideo = scrapy.Field(
input_processor = MapCompose(clean_url)
)
2018-05-11 22:46:01 +00:00
urlCF = scrapy.Field()
date_event = scrapy.Field(
input_processor = MapCompose(clean_text, format_date)
)
2018-05-11 22:46:01 +00:00
tags = scrapy.Field()
biographies = scrapy.Field()
2018-05-10 17:31:59 +00:00
pass