Update New Scientist

This commit is contained in:
Kovid Goyal 2023-03-05 19:57:23 +05:30
parent 8a0e91a2e9
commit 2a286eb0f0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -64,11 +64,11 @@ class NewScientist(BasicNewsRecipe):
""" """
keep_only_tags = [ keep_only_tags = [
classes('article-header article__content') classes('article-header article__content ArticleHeader ArticleContent')
] ]
remove_tags = [ remove_tags = [
classes('social__button-container') classes('social__button-container ArticleHeader__SocialWrapper')
] ]
def preprocess_html(self, soup): def preprocess_html(self, soup):
@ -83,6 +83,11 @@ class NewScientist(BasicNewsRecipe):
ans = BasicNewsRecipe.get_article_url(self, article) ans = BasicNewsRecipe.get_article_url(self, article)
return ans.partition('?')[0] return ans.partition('?')[0]
def print_version(self, url):
if '/video/' in url:
return None
return url
def get_browser(self): def get_browser(self):
br = BasicNewsRecipe.get_browser(self) br = BasicNewsRecipe.get_browser(self)
if self.username is not None and self.password is not None: if self.username is not None and self.password is not None:
@ -94,7 +99,7 @@ class NewScientist(BasicNewsRecipe):
br['email'] = self.username br['email'] = self.username
br['password'] = self.password br['password'] = self.password
res = br.submit().read() res = br.submit().read()
if b'>Log out<' not in res: if b'>Your account<' not in res:
raise ValueError('Failed to log in to New Scientist, check your username and password') raise ValueError('Failed to log in to New Scientist, check your username and password')
return br return br