Debian Codegraph @

recipes/ba_herald.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2012, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 www.buenosairesherald.com
5 '''
6
7 from calibre import strftime
8 from calibre.web.feeds.news import BasicNewsRecipe
9
10
11 class BuenosAiresHerald(BasicNewsRecipe):
12 title = 'Buenos Aires Herald'
13 __author__ = 'Darko Miletic'
14 description = 'A world of information in a few words'
15 publisher = 'Editorial Nefir S.A.'
16 category = 'news, politics, Argentina'
17 oldest_article = 2
18 max_articles_per_feed = 200
19 no_stylesheets = True
20 encoding = 'utf8'
21 use_embedded_content = False
22 language = 'en_AR'
23 remove_empty_feeds = True
24 publication_type = 'newspaper'
25 masthead_url = 'http://www.buenosairesherald.com/img/logo.jpg'
26 INDEX = 'http://www.buenosairesherald.com'
27 extra_css = '''
28 body{font-family: Arial,Helvetica,sans-serif }
29 img{margin-bottom: 0.4em; display:block}
30 h1{font-family: Georgia,serif}
31 #fecha{text-align: right; font-size: small}
32 '''
33
34 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}
35
36 remove_tags = [dict(name=['meta', 'link', 'iframe'])]
37 keep_only_tags = [dict(attrs={'class': 'nota_texto p'})]
38
39 feeds = [
40 ('Argentina', 'http://www.buenosairesherald.com/argentina'),
41 ('World', 'http://www.buenosairesherald.com/world'),
42 ('Latin America', 'http://www.buenosairesherald.com/latin-america'),
43 ('Sports', 'http://www.buenosairesherald.com/sports'),
44 ]
45
46 def print_version(self, url):
47 artidraw = url.rpartition('/article/')[2]
48 artid = artidraw.partition('/')[0]
49 return 'http://www.buenosairesherald.com/articles/print.aspx?ix=' + artid
50
51 def parse_index(self):
52 totalfeeds = []
53 lfeeds = self.get_feeds()
54 for feedobj in lfeeds:
55 feedtitle, feedurl = feedobj
56 self.report_progress(0, ('Fetching feed') + ' %s...' % (feedtitle or feedurl))
57 articles = []
58 soup = self.index_to_soup(feedurl)
59 for item in soup.findAll('div', attrs={'class': 'nota_texto_seccion'}):
60 description = self.tag_to_string(item.h2)
61 atag = item.h2.find('a', href=True)
62 if atag is not None:
63 url = self.INDEX + atag['href']
64 title = description
65 date = strftime(self.timefmt)
66 articles.append({'title': title, 'date': date, 'url': url, 'description': description})
67 totalfeeds.append((feedtitle, articles))
68 return totalfeeds