From 391e9d3f394a77522ff66858ce23627e6e043dc3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 15 Apr 2021 20:22:52 +0530 Subject: [PATCH] Update New Scientist --- recipes/new_scientist.recipe | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/recipes/new_scientist.recipe b/recipes/new_scientist.recipe index b64a65d6f1..cc4faf6e8b 100644 --- a/recipes/new_scientist.recipe +++ b/recipes/new_scientist.recipe @@ -64,13 +64,21 @@ class NewScientist(BasicNewsRecipe): """ keep_only_tags = [ - classes('article-header article-conten') + classes('article-header article__content') ] remove_tags = [ classes('social__button-container') ] + def preprocess_html(self, soup): + for img in soup.findAll('img', attrs={'data-src': True}): + img['src'] = img['data-src'] + for img in soup.findAll('img', attrs={'data-srcset': True}): + img['src'] = img['data-srcset'].split(',')[-1].strip().split()[0] + img['width'] = img['height'] = '' + return soup + def get_article_url(self, article): ans = BasicNewsRecipe.get_article_url(self, article) return ans.partition('?')[0]