Debian Codegraph @

recipes/el_pais_uy.recipe

raw
1 #!/usr/bin/env python
2 ##
3 # Last Edited: 2018-02-13 Carlos Alves <[email protected]>
4 ##
5
6 __license__ = 'GPL v3'
7 __author__ = '2010, Gustavo Azambuja <hola at gazambuja.com>'
8 '''
9 http://www.elpais.com.uy/
10 '''
11
12 from calibre.web.feeds.news import BasicNewsRecipe
13
14
15 class General(BasicNewsRecipe):
16 title = 'El Pais - Uruguay'
17 __author__ = 'Gustavo Azambuja'
18 description = 'Noticias de Uruguay y el resto del mundo'
19 publisher = 'EL PAIS S.A.'
20 category = 'news, politics, Uruguay'
21 language = 'es_UY'
22 timefmt = '[%a, %d %b, %Y]'
23 use_embedded_content = False
24 recursion = 2
25 encoding = 'utf-8'
26 publication_type = 'newspaper'
27 remove_javascript = True
28 no_stylesheets = True
29
30 oldest_article = 2
31 max_articles_per_feed = 20
32 keep_only_tags = [
33 dict(name='h1', attrs={'class': 'title'}),
34 dict(name='div', attrs={'class': 'composite-captioned-image'}),
35 dict(name='div', attrs={'class': 'content-modules'}),
36 ]
37
38 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}
39 remove_tags = [
40 dict(name='div', attrs={'class': ['date_text', 'comments', 'form_section', 'share_it']}),
41 dict(name='div', attrs={'id': ['relatedPosts', 'spacer', 'banner_izquierda', 'right_container']}),
42 dict(name='p', attrs={'class': 'FacebookLikeButton'}),
43 dict(name=['object', 'form']),
44 dict(name=['object', 'table']),
45 ]
46
47 extra_css = '''
48 h1{font-family: Georgia,"Times New Roman",Times,serif}
49 h3{font-family: Georgia,"Times New Roman",Times,serif}
50 h2{font-family: Georgia,"Times New Roman",Times,serif}
51 p{font-family: Verdana,Arial,Helvetica,sans-serif}
52 body{font-family: Verdana,Arial,Helvetica,sans-serif}
53 img{margin-bottom: 0.4em; display:block;}
54 '''
55
56 feeds = [('Ultimo Momento', 'https://www.elpais.com.uy/rss/')]
57
58 def get_cover_url(self):
59 cover_url = None
60 index = 'https://www.elpais.com.uy/impresa/'
61 soup = self.index_to_soup(index)
62 link_item = soup.find('a', attrs={'class': 'page-link link-module'})
63 # print(link_item)
64 if link_item:
65 cover_url = 'https://www.elpais.com.uy' + link_item.get('href')
66 return cover_url
67
68 def preprocess_html(self, soup):
69 for item in soup.findAll(style=True):
70 del item['style']
71 return soup