| 1 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 2 |
|
| 3 |
|
| 4 |
class ElFaroDeVigo(BasicNewsRecipe): |
| 5 |
title = 'El Faro de Vigo' |
| 6 |
oldest_article = 1 |
| 7 |
max_articles_per_feed = 100 |
| 8 |
__author__ = 'Jefferson Frantz' |
| 9 |
description = 'Noticias de Vigo' |
| 10 |
timefmt = ' [%d %b, %Y]' |
| 11 |
language = 'es' |
| 12 |
encoding = 'cp1252' |
| 13 |
no_stylesheets = True |
| 14 |
remove_javascript = True |
| 15 |
|
| 16 |
feeds = [ |
| 17 |
('Galicia', 'http://www.farodevigo.es/elementosInt/rss/4'), |
| 18 |
('España', 'http://www.farodevigo.es/elementosInt/rss/6'), |
| 19 |
('Mundo', 'http://www.farodevigo.es/elementosInt/rss/7'), |
| 20 |
('Economía', 'http://www.farodevigo.es/elementosInt/rss/10'), |
| 21 |
('Sociedad y Cultura', 'http://www.farodevigo.es/elementosInt/rss/8'), |
| 22 |
('Sucesos', 'http://www.farodevigo.es/elementosInt/rss/9'), |
| 23 |
('Deportes', 'http://www.farodevigo.es/elementosInt/rss/11'), |
| 24 |
('Agenda', 'http://www.farodevigo.es/elementosInt/rss/21'), |
| 25 |
('Gente', 'http://www.farodevigo.es/elementosInt/rss/24'), |
| 26 |
('Televisión', 'http://www.farodevigo.es/elementosInt/rss/25'), |
| 27 |
('Ciencia y Tecnología', 'http://www.farodevigo.es/elementosInt/rss/26'), |
| 28 |
] |
| 29 |
|
| 30 |
extra_css = '''.noticia_texto{ font-family: sans-serif; font-size: medium; text-align: justify } |
| 31 |
h1{font-family: serif; font-size: x-large; font-weight: bold; color: #000000; text-align: center} |
| 32 |
h2{font-family: serif; font-size: medium; font-weight: bold; color: #000000; text-align: left} |
| 33 |
.enlacenegrita10{font-family: serif; font-size: small; font-weight: bold; color: #000000; text-align: left} |
| 34 |
.noticia_titular{font-family: serif; font-size: x-large; font-weight: bold; color: #000000; text-align: center}''' |
| 35 |
|
| 36 |
def preprocess_html(self, soup): |
| 37 |
for item in soup.findAll(style=True): |
| 38 |
del item['style'] |
| 39 |
|
| 40 |
url = 'http://estaticos00.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif' |
| 41 |
fitem = soup.find('img', src=url) |
| 42 |
if fitem: |
| 43 |
par = fitem.parent |
| 44 |
par.extract() |
| 45 |
url = 'http://estaticos01.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif' |
| 46 |
fitem = soup.find('img', src=url) |
| 47 |
if fitem: |
| 48 |
par = fitem.parent |
| 49 |
par.extract() |
| 50 |
url = 'http://estaticos02.farodevigo.es//elementosWeb/mediaweb/images/compartir/barrapunto.gif' |
| 51 |
fitem = soup.find('img', src=url) |
| 52 |
if fitem: |
| 53 |
par = fitem.parent |
| 54 |
par.extract() |
| 55 |
|
| 56 |
return self.adeify_images(soup) |
| 57 |
|
| 58 |
def postprocess_html(self, soup, first_fetch): |
| 59 |
divs = soup.findAll(True, {'class': 'enlacenegrita10'}) |
| 60 |
for div in divs: |
| 61 |
div['align'] = 'left' |
| 62 |
|
| 63 |
return soup |
| 64 |
|
| 65 |
keep_only_tags = [dict(name='div', attrs={'class': ['noticias']})] |
| 66 |
|
| 67 |
remove_tags = [ |
| 68 |
dict(name=['object', 'link', 'script', 'ul', 'iframe', 'ol']), |
| 69 |
dict(name='div', attrs={'class': ['noticiadd2', 'cintillo2', 'noticiadd', 'noticiadd2']}), |
| 70 |
dict(name='div', attrs={'class': ['imagen_derecha', 'noticiadd3', 'extraHTML']}), |
| 71 |
] |