From 5ba018e7ed4a7617323377451eb2364f7eaf7ff2 Mon Sep 17 00:00:00 2001 From: a10kiloham Date: Wed, 18 Jul 2018 12:34:24 +0100 Subject: [PATCH] Remove other tag cruft --- recipes/sunday_times_magazine.recipe | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/recipes/sunday_times_magazine.recipe b/recipes/sunday_times_magazine.recipe index a5f9276e8d..6410df2c49 100644 --- a/recipes/sunday_times_magazine.recipe +++ b/recipes/sunday_times_magazine.recipe @@ -39,6 +39,11 @@ class TimesOnline(BasicNewsRecipe): 'publisher': publisher, 'language': language} + def classes(classes): + q = frozenset(classes.split(' ')) + return dict(attrs={ + 'class': lambda x: x and frozenset(x.split()).intersection(q)}) + def get_browser(self): br = BasicNewsRecipe.get_browser(self) br.open('http://www.thetimes.co.uk/') @@ -74,9 +79,9 @@ class TimesOnline(BasicNewsRecipe): cover = None return cover - remove_tags = [{ - 'attrs': {'class': lambda x: x and 'is-hidden' in x.split()}, - 'name': ['object', 'link', 'iframe', 'base', 'meta', 'script']}, { + remove_tags = [ + classes('Topics is-hidden Tooltip Toolbar Comments RelatedLinks'), + {'name': ['object', 'link', 'iframe', 'base', 'meta', 'script']}, { 'attrs': { 'class': [ 'tools comments-parent', 'u-hide', 'Tooltip',