Debian Codegraph @

recipes/focus_de.recipe

raw
1 """
2 focus.de
3 """
4
5 from calibre.web.feeds.news import BasicNewsRecipe, classes
6
7
8 class AdvancedUserRecipe1305567197(BasicNewsRecipe):
9 title = 'Focus (DE)'
10 __author__ = 'unkn0wn'
11 description = 'RSS-Feeds von Focus.de, best downloaded at the end of the week.'
12 language = 'de'
13
14 oldest_article = 7
15 max_articles_per_feed = 25
16 no_stylesheets = True
17 remove_javascript = True
18 use_embedded_content = False
19 remove_empty_feeds = True
20 ignore_duplicate_articles = {'title', 'url'}
21 remove_attributes = ['width', 'height', 'style']
22 masthead_url = 'https://www.focus-magazin.de/img/Focus_Logo.jpg'
23 extra_css = '''
24 .posMarker_oh { font-size:small; color:#404040; }
25 .posMarker_he { font-size:large; font-weight:bold; }
26 .leadIn { font-style:italic; color:#202020; }
27 .caption { text-align:center; font-size:small; }
28 .authorMeta, .displayDate { font-size:small; }
29 '''
30
31 def get_cover_url(self):
32 soup = self.index_to_soup('https://www.focus-magazin.de/')
33 return soup.find('img', attrs={'class': 'main-cover'})['src']
34
35 feeds = [
36 ('Politik', 'http://rss.focus.de/politik/'),
37 ('Finanzen', 'http://rss.focus.de/finanzen/'),
38 ('Gesundheit', 'http://rss.focus.de/gesundheit/'),
39 ('Panorama', 'http://rss.focus.de/panorama/'),
40 ('Digital', 'http://rss.focus.de/digital/'),
41 ('Reisen', 'http://rss.focus.de/reisen/'),
42 ('Andere', 'http://rss.focus.de'),
43 ]
44
45 keep_only_tags = [classes('articleHead articleContent')]
46
47 remove_tags = [dict(name=['svg', 'script']), classes('socFbLikeShare video social_frame'), dict(attrs={'id': 'article-social-holder'})]
48
49 def preprocess_html(self, soup):
50 if h1 := soup.find(attrs={'class': 'articleIdentH1'}):
51 h1.name = 'h1'
52 if he := soup.find(**classes('posMarker_he')):
53 he.name = 'div'
54 for img in soup.findAll('img', attrs={'data-src': True}):
55 img['src'] = img['data-src']
56 return soup