Debian Codegraph @

recipes/laprensa.recipe

raw
1 #!/usr/bin/env python
2 # -*- mode: python -*-
3 # -*- coding: utf-8 -*-
4
5 __license__ = 'GPL v3'
6 __copyright__ = '2008-2016, Darko Miletic <darko.miletic at gmail.com>'
7 '''
8 laprensa.com.ar
9 '''
10
11 from calibre.web.feeds.news import BasicNewsRecipe
12
13
14 class LaPrensa(BasicNewsRecipe):
15 title = 'La Prensa'
16 __author__ = 'Darko Miletic and Sujata Raman'
17 description = 'Informacion Libre las 24 horas'
18 publisher = 'La Prensa'
19 category = 'news, politics, Argentina'
20 oldest_article = 7
21 max_articles_per_feed = 100
22 no_stylesheets = True
23 use_embedded_content = False
24 encoding = 'utf8'
25 remove_javascript = True
26 language = 'es_AR'
27 lang = 'es'
28
29 html2lrf_options = ['--comment', description, '--category', category, '--publisher', publisher]
30
31 html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
32 filter_regexps = [r'.*archive.aspx.*']
33
34 remove_tags = [
35 dict(name='td', attrs={'class': ['link-registro', 'link-buscador']}),
36 dict(name='td', attrs={'id': ['TDTabItem1', 'TDTabItem2', 'TDTabItem3', 'TDTabItem4']}),
37 dict(name='table', attrs={'class': ['marco-botonera']}),
38 dict(name='tr', attrs={'class': ['messages', 'IUTabItemSelected']}),
39 dict(name='input', attrs={'id': 'txt_allfields'}),
40 dict(name='div', attrs={'id': ['TabItem1', 'TabItem2', 'TabItem3', 'TabItem4', 'RCPanel']}),
41 dict(name='span', attrs={'id': ['GWCNavigatorControl', '_ctl15']}),
42 dict(name='span', attrs={'class': ['ranking-titulo', 'IUTab']}),
43 dict(
44 name='a',
45 attrs={
46 'class': [
47 'link-registro',
48 ]
49 },
50 ),
51 dict(name='img', src='/versions/1/imgs/icono-comentario.gif'),
52 dict(name='img', src='/versions/1/imgs/logo.gif'),
53 dict(name='img', src='/versions/1/imgs/boton-ingresar-roll.gif'),
54 dict(name='img', src='/versions/1/imgs/icono-recomendar.gif'),
55 dict(name='button'),
56 dict(name='img', src='/versions/1/imgs/boton-votar-roll.gif'),
57 dict(name='img', src='/versions/1/imgs/boton-ingresar.gif'),
58 dict(name='img', src='/versions/1/imgs/icono-imprimir.gif'),
59 dict(name='img', src='/versions/1/imgs/icono-ampliar-letra.gif'),
60 dict(name='img', src='/versions/1/imgs/icono-reducir-letra.gif'),
61 dict(name='img', src='/versions/1/imgs/pix-trans.gif'),
62 dict(name='img', src='/versions/1/imgs/icono-buscador.gif'),
63 dict(name='img', src='/versions/1/imgs/separador-linea-azul.gif'),
64 dict(name='img', src=' /versions/1/imgs/separador-linea.gif'),
65 dict(name='a', text='Powered by Civinext Groupware - V. 2.0.3567.23706'),
66 dict(name='img', height='0'),
67 ]
68
69 extra_css = '''
70 .seccion{font-size:xx-small;}
71 body{font-family:Arial,Helvetica,sans-serif;font-size:x-small;}
72 .titulo-noticia-principal{font-size:large; color:#00427B; font-weight:bold;}
73 .texto-subtitulos{font-weight:bold;font-size:x-small;}
74 .fecha{font-size:xx-small;}
75 .volanta{font-size:xx-small;}
76 '''
77
78 feeds = [
79 ('Politica', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx&Rss=4'),
80 ('Economia', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx&Rss=5'),
81 ('Opinion', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx?Rss=6'),
82 ('El Mundo', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx?Rss=7'),
83 ('Actualidad', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx?Rss=8'),
84 ('Deportes', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx?Rss=9'),
85 ('Espectaculos', 'http://www.laprensa.com.ar/ResourcesManager.aspx?Resource=Rss.aspx?Rss=10'),
86 ]
87
88 def preprocess_html(self, soup):
89
90 for t in soup.findAll(['table', 'td', 'tr', 'span', 'tbody']):
91 t.name = 'div'
92 for t in soup.findAll(['hr']):
93 t.extract()
94
95 mtag = '<meta http-equiv="Content-Language" content="es-AR"/>'
96 soup.head.insert(0, mtag)
97 for item in soup.findAll(style=True):
98 del item['style']
99 for item in soup.findAll(align='center'):
100 del item['align']
101 for item in soup.findAll(bgcolor='ffffff'):
102 del item['bgcolor']
103 return soup