Debian Codegraph @

recipes/folha.recipe

raw
1 # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
2
3 __license__ = 'GPL v3'
4 __copyright__ = '2012, Darko Miletic <darko.miletic at gmail.com>'
5 '''
6 www.folha.uol.com.br
7 '''
8 from calibre.web.feeds.news import BasicNewsRecipe
9
10 try:
11 from urllib.parse import quote_plus
12 except ImportError:
13 from urllib import quote_plus
14
15
16 class Folha_de_s_paulo(BasicNewsRecipe):
17 title = 'Folha de São Paulo - portal'
18 __author__ = 'Darko Miletic'
19 description = 'Um Jornala a servicao do Brasil'
20 publisher = 'Folhapress'
21 category = 'news, politics, Brasil'
22 oldest_article = 2
23 max_articles_per_feed = 200
24 no_stylesheets = True
25 encoding = 'cp1252'
26 use_embedded_content = False
27 language = 'pt_BR'
28 remove_empty_feeds = True
29 publication_type = 'newspaper'
30 masthead_url = 'http://f.i.uol.com.br/fsp/furniture/images/lgo-fsp-430x50-ffffff.gif'
31 extra_css = '''
32 body{font-family: Arial,Helvetica,sans-serif }
33 img{margin-bottom: 0.4em; display:block}
34 '''
35
36 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}
37
38 remove_tags = [dict(name=['meta', 'link', 'base', 'iframe', 'embed', 'object'])]
39 keep_only_tags = [dict(attrs={'id': 'articleNew'})]
40
41 feeds = [
42 ('Poder', 'http://feeds.folha.uol.com.br/poder/rss091.xml'),
43 ('Mundo', 'http://feeds.folha.uol.com.br/mundo/rss091.xml'),
44 ('Mercado', 'http://feeds.folha.uol.com.br/mercado/rss091.xml'),
45 ('Cotidiano', 'http://feeds.folha.uol.com.br/cotidiano/rss091.xml'),
46 ('Esporte', 'http://feeds.folha.uol.com.br/esporte/rss091.xml'),
47 ('Ilustrada', 'http://feeds.folha.uol.com.br/ilustrada/rss091.xml'),
48 ('F5', 'http://feeds.folha.uol.com.br/f5/rss091.xml'),
49 ('Ciência', 'http://feeds.folha.uol.com.br/ciencia/rss091.xml'),
50 ('Tec', 'http://feeds.folha.uol.com.br/tec/rss091.xml'),
51 ('Ambiente', 'http://feeds.folha.uol.com.br/ambiente/rss091.xml'),
52 ('Bichos', 'http://feeds.folha.uol.com.br/bichos/rss091.xml'),
53 ('Celebridades', 'http://feeds.folha.uol.com.br/celebridades/rss091.xml'),
54 ('Comida', 'http://feeds.folha.uol.com.br/comida/rss091.xml'),
55 ('Equilibrio', 'http://feeds.folha.uol.com.br/equilibrioesaude/rss091.xml'),
56 ('Folhateen', 'http://feeds.folha.uol.com.br/folhateen/rss091.xml'),
57 ('Folhinha', 'http://feeds.folha.uol.com.br/folhinha/rss091.xml'),
58 ('Ilustrissima', 'http://feeds.folha.uol.com.br/ilustrissima/rss091.xml'),
59 ('Saber', 'http://feeds.folha.uol.com.br/saber/rss091.xml'),
60 ('Turismo', 'http://feeds.folha.uol.com.br/turismo/rss091.xml'),
61 ('Panel do Leitor', 'http://feeds.folha.uol.com.br/folha/paineldoleitor/rss091.xml'),
62 ('Publifolha', 'http://feeds.folha.uol.com.br/folha/publifolha/rss091.xml'),
63 ('Em cima da hora', 'http://feeds.folha.uol.com.br/emcimadahora/rss091.xml'),
64 ]
65
66 def get_article_url(self, article):
67 url = BasicNewsRecipe.get_article_url(self, article)
68 curl = url.partition('/*')[2]
69 return curl
70
71 def print_version(self, url):
72 return 'http://tools.folha.com.br/print?site=emcimadahora&url=' + quote_plus(url)
73
74 def get_cover_url(self):
75 soup = self.index_to_soup('http://www.folha.uol.com.br/')
76 cont = soup.find('div', attrs={'id': 'newspaper'})
77 if cont:
78 ai = cont.find('a', href='http://www1.folha.uol.com.br/fsp/')
79 if ai:
80 return ai.img['src']
81 return None