Debian Codegraph @

recipes/nakedcapitalism.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class NakedCapitalism(BasicNewsRecipe):
7 title = 'Naked Capitalism'
8 oldest_article = 7
9 max_articles_per_feed = 100
10 auto_cleanup = True
11
12 extra_css = '''
13 body { font-family: serif !important; color: black !important; }
14 p { display: block !important; margin-bottom: 1em !important; line-height: 1.4 !important; }
15 div, article, section {
16 width: auto !important;
17 height: auto !important;
18 overflow: visible !important;
19 display: block !important;
20 }
21 '''
22
23 def preprocess_html(self, soup):
24 for tag in soup.findAll(['script', 'style', 'iframe']):
25 tag.decompose()
26 for tag in soup.findAll(True):
27 if tag.has_attr('style'):
28 del tag['style']
29 if tag.has_attr('srcset'):
30 del tag['srcset']
31 return soup
32
33 def get_browser(self):
34 br = BasicNewsRecipe.get_browser(self)
35 br.set_handle_robots(False)
36 br.addheaders = [
37 ('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0'),
38 ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'),
39 ('Accept-Language', 'en-US,en;q=0.5'),
40 ('Accept-Encoding', 'gzip, deflate, br'),
41 ('Connection', 'keep-alive'),
42 ]
43 return br
44
45 feeds = [
46 ('Naked Capitalism', 'https://www.nakedcapitalism.com/feed'),
47 ]