Debian Codegraph @

recipes/hoy.recipe

raw
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 __license__ = 'GPL v3'
5 __copyright__ = '2010, Francisco Javier Nieto <frjanibo at gmail.com>'
6 '''
7 www.hoy.es
8 '''
9
10 from calibre.ebooks.BeautifulSoup import Tag
11 from calibre.web.feeds.news import BasicNewsRecipe
12
13
14 def new_tag(soup, name, attrs=()):
15 impl = getattr(soup, 'new_tag', None)
16 if impl is not None:
17 return impl(name, attrs=dict(attrs))
18 return Tag(soup, name, attrs=attrs or None)
19
20
21 class Hoy(BasicNewsRecipe):
22 title = 'HOY'
23 __author__ = 'Fco Javier Nieto'
24 description = 'Noticias desde Extremadura'
25 publisher = 'HOY'
26 category = 'news, politics, Spain, Extremadura'
27 oldest_article = 2
28 max_articles_per_feed = 100
29 no_stylesheets = True
30 use_embedded_content = False
31 delay = 1
32 encoding = 'cp1252'
33 language = 'es'
34
35 feeds = [
36 ('Portada', 'http://www.hoy.es/portada.xml'),
37 ('Regional', 'http://www.hoy.es/rss/feeds/regional.xml'),
38 ('Prov de Badajoz', 'http://www.hoy.es/rss/feeds/prov_badajoz.xml'),
39 ('Prov de Caceres', 'http://www.hoy.es/rss/feeds/prov_caceres.xml'),
40 ('Badajoz', 'http://www.hoy.es/rss/feeds/badajoz.xml'),
41 ('Caceres', 'http://www.hoy.es/rss/feeds/caceres.xml'),
42 ('Merida', 'http://www.hoy.es/rss/feeds/merida.xml'),
43 ('Opinion', 'http://www.hoy.es/rss/feeds/opinion.xml'),
44 ('Nacional', 'http://www.hoy.es/rss/feeds/nacional.xml'),
45 ('Internacional', 'http://www.hoy.es/rss/feeds/internacional.xml'),
46 ('Economia', 'http://www.hoy.es/rss/feeds/economia.xml'),
47 ('Deportes', 'http://www.hoy.es/rss/feeds/deportes.xml'),
48 ('Sociedad', 'http://www.hoy.es/rss/feeds/sociedad.xml'),
49 ('Cultura', 'http://www.hoy.es/rss/feeds/cultura.xml'),
50 ('Television', 'http://www.hoy.es/rss/feeds/television.xml'),
51 ('contraportada', 'http://www.hoy.es/rss/feeds/contraportada.xml'),
52 ]
53
54 keep_only_tags = [
55 dict(name='h1', attrs={'class': ['headline']}),
56 dict(name='h2', attrs={'class': ['subhead']}),
57 dict(name='div', attrs={'class': ['text']}),
58 ]
59
60 remove_tags = [dict(name=['object', 'link', 'script']), dict(name='div', attrs={'class': ['colC_articulo', 'peu']})]
61
62 remove_tags_after = [dict(name='div', attrs={'class': 'text'})]
63
64 extra_css = '.headline {font: sans-serif 2em;}\n.subhead,h2{font: sans-serif 1.5em\n'
65
66 def preprocess_html(self, soup):
67 soup.html['dir'] = self.direction
68 mcharset = new_tag(soup, 'meta', [('http-equiv', 'Content-Type'), ('content', 'text/html; charset=utf-8')])
69 soup.head.insert(0, mcharset)
70 for item in soup.findAll(style=True):
71 del item['style']
72 return soup