#!/usr/bin/env python # vim:fileencoding=utf-8 from calibre.web.feeds.news import BasicNewsRecipe class NakedCapitalism(BasicNewsRecipe): title = 'Naked Capitalism' oldest_article = 7 max_articles_per_feed = 100 auto_cleanup = True extra_css = ''' body { font-family: serif !important; color: black !important; } p { display: block !important; margin-bottom: 1em !important; line-height: 1.4 !important; } div, article, section { width: auto !important; height: auto !important; overflow: visible !important; display: block !important; } ''' def preprocess_html(self, soup): for tag in soup.findAll(['script', 'style', 'iframe']): tag.decompose() for tag in soup.findAll(True): if tag.has_attr('style'): del tag['style'] if tag.has_attr('srcset'): del tag['srcset'] return soup def get_browser(self): br = BasicNewsRecipe.get_browser(self) br.set_handle_robots(False) br.addheaders = [ ('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'), ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'), ('Accept-Language', 'en-US,en;q=0.5'), ('Accept-Encoding', 'gzip, deflate, br'), ('Connection', 'keep-alive'), ] return br feeds = [ ('Naked Capitalism', 'https://www.nakedcapitalism.com/feed'), ]