From 8db5fff5acc01a73feb12f2071df66854eefe4ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Nov 2022 08:11:22 +0530 Subject: [PATCH] Update Spectator Magazine --- recipes/spectator_magazine.recipe | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/recipes/spectator_magazine.recipe b/recipes/spectator_magazine.recipe index e9ce4a4da0..aee63e9b42 100644 --- a/recipes/spectator_magazine.recipe +++ b/recipes/spectator_magazine.recipe @@ -1,4 +1,5 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes +from calibre import browser def absurl(url): @@ -32,13 +33,13 @@ class spectator(BasicNewsRecipe): ] remove_tags = [ - classes('entry-header__author entry-header__meta entry-meta insert--most-popular') + classes( + 'entry-header__author entry-header__meta entry-meta insert--most-popular ' + 'subscribe-ribbon subscription-banner paywall__card' + ) ] def preprocess_html(self, soup): - h2 = soup.find('h2') - if h2: - h2.name = 'h4' for fc in soup.findAll('figcaption'): fc['id'] = 'fig-c' return soup @@ -93,3 +94,17 @@ class spectator(BasicNewsRecipe): self.log('\t', title, '\n\t', desc, '\n\t\t', url) ans.append({'title': title, 'description':desc, 'url': url}) return ans + + # Spectator changes the content it delivers based on cookies, so the + # following ensures that we send no cookies + def get_browser(self, *args, **kwargs): + return self + + def clone_browser(self, *args, **kwargs): + return self.get_browser() + + def open_novisit(self, *args, **kwargs): + br = browser() + return br.open_novisit(*args, **kwargs) + + open = open_novisit