Debian Codegraph @

recipes/financialsense.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 www.financialsense.com
5 '''
6
7 from calibre.web.feeds.news import BasicNewsRecipe
8
9
10 class FinancialSense(BasicNewsRecipe):
11 title = 'Financial Sense'
12 __author__ = 'Darko Miletic'
13 description = 'Uncommon News & Views for the Wise Investor'
14 publisher = 'Financial Sense'
15 category = 'news, finances, politics, USA'
16 oldest_article = 2
17 max_articles_per_feed = 200
18 no_stylesheets = True
19 encoding = 'utf8'
20 use_embedded_content = False
21 language = 'en'
22 remove_empty_feeds = True
23 publication_type = 'newsportal'
24 masthead_url = 'http://www.financialsense.com/sites/default/files/logo.jpg'
25 extra_css = '''
26 body{font-family: Arial,"Helvetica Neue",Helvetica,sans-serif }
27 img{margin-bottom: 0.4em; display:block}
28 h2{color: gray}
29 .name{margin-right: 5em}
30 '''
31
32 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language}
33
34 remove_tags = [dict(name=['meta', 'link', 'base', 'object', 'embed', 'iframe'])]
35 remove_tags_after = dict(attrs={'class': 'vcard'})
36 keep_only_tags = [dict(attrs={'class': ['title', 'post-meta', 'content', 'item-title', 'vcard']})]
37 remove_attributes = ['lang', 'type']
38
39 feeds = [('Articles', 'http://feeds.feedburner.com/fso')]
40
41 def preprocess_html(self, soup):
42 for item in soup.findAll(style=True):
43 del item['style']
44 for item in soup.findAll('a'):
45 limg = item.find('img')
46 if item.string is not None:
47 str = item.string
48 item.replaceWith(str)
49 elif limg:
50 item.name = 'div'
51 item.attrs = []
52 else:
53 str = self.tag_to_string(item)
54 item.replaceWith(str)
55 for item in soup.findAll('img', alt=False):
56 item['alt'] = 'image'
57 return soup