Debian Codegraph @

recipes/propublica.recipe

raw
1 from calibre.web.feeds.news import BasicNewsRecipe
2
3
4 def classes(classes):
5 q = frozenset(classes.split(' '))
6 return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
7
8
9 class ProPublicaRecipe(BasicNewsRecipe):
10 __license__ = 'GPL v3'
11 __author__ = 'kwetal'
12 language = 'en'
13 version = 1
14
15 title = 'Pro Publica'
16 publisher = 'ProPublica.org'
17 category = 'Political blog'
18 description = 'Independent investigative journalism in the public interest.'
19
20 oldest_article = 14
21 max_articles_per_feed = 100
22 use_embedded_content = False
23
24 remove_empty_feeds = True
25 no_stylesheets = True
26 remove_javascript = True
27
28 keep_only_tags = [classes('title-wrapper content-wrapper article-header lead-art article-body')]
29 remove_tags = [
30 classes('email-signup story-tools newsletter topics-list'),
31 classes('wp-block-propublica-notes--top'),
32 ]
33 remove_tags_after = classes('article-body')
34
35 feeds = [
36 ('Top Stories', 'http://feeds.propublica.org/propublica/main'),
37 ]
38
39 def preprocess_html(self, soup):
40 for img in soup.findAll('img', **classes('lazyload')):
41 source = img.findParent('picture')
42 if source is not None:
43 source = source.find('source')
44 if source is not None:
45 img['src'] = source['data-srcset']
46 for img in soup.findAll('img', srcset=True):
47 img['src'] = img['srcset'].split()[0]
48 return soup