From c33d89f0c5e8f81aac5667c9e727551ae64940a9 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:16:02 +0530 Subject: [PATCH 1/2] Update scientific_american.recipe remove p tags in captions --- recipes/scientific_american.recipe | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/scientific_american.recipe b/recipes/scientific_american.recipe index 3bf5959d39..345c1fefba 100644 --- a/recipes/scientific_american.recipe +++ b/recipes/scientific_american.recipe @@ -44,6 +44,12 @@ class ScientificAmerican(BasicNewsRecipe): dict(name=['button', 'svg', 'iframe', 'source']) ] + def preprocess_html(self, soup): + for fig in soup.findAll('figcaption'): + for p in fig.findAll('p'): + p.name = 'span' + return soup + def get_browser(self, *args): br = BasicNewsRecipe.get_browser(self) if self.username and self.password: From 8a3606a69fd9ee70bb74954ed8fab51fa4b5eb35 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:17:23 +0530 Subject: [PATCH 2/2] Update economist.recipe --- recipes/economist.recipe | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 0b0bcc294f..325ef8ee43 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -126,6 +126,7 @@ class Economist(BasicNewsRecipe): title = 'The Economist' language = 'en' encoding = 'utf-8' + masthead_url = 'https://www.livemint.com/lm-img/dev/economist-logo-oneline.png' __author__ = "Kovid Goyal" description = ( @@ -156,6 +157,7 @@ class Economist(BasicNewsRecipe): font-size: smaller; color: red; } + img {display:block; margin:0 auto;} ''' oldest_article = 7.0 resolve_internal_links = True @@ -251,6 +253,11 @@ class Economist(BasicNewsRecipe): x.text = x.text.upper() x.tag = 'span' x.set('style', 'font-variant: small-caps') + for x in root.xpath('//figcaption'): + x.set('style', 'text-align:center; font-size:small;') + for x in root.xpath('//cite'): + x.tag = 'blockquote' + x.set('style', 'color:#404040;') raw = etree.tostring(root, encoding='unicode') return raw @@ -295,6 +302,8 @@ class Economist(BasicNewsRecipe): if script_tag is not None: data = json.loads(script_tag.string) # open('/t/raw.json', 'w').write(json.dumps(data, indent=2, sort_keys=True)) + self.title = 'The Economist | ' + safe_dict(data, "props", "pageProps", "content", "image", "main", "headline") + self.timefmt = ' [' + safe_dict(data, "props", "pageProps", "content", "datePublishedString") + ']' self.cover_url = safe_dict(data, "props", "pageProps", "content", "image", "main", "url", "canonical") self.log('Got cover:', self.cover_url)