Remove other tag cruft

This commit is contained in:
a10kiloham 2018-07-18 12:34:24 +01:00 committed by GitHub
parent d1395dba2b
commit 5ba018e7ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,11 @@ class TimesOnline(BasicNewsRecipe):
'publisher': publisher, 'publisher': publisher,
'language': language} '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): def get_browser(self):
br = BasicNewsRecipe.get_browser(self) br = BasicNewsRecipe.get_browser(self)
br.open('http://www.thetimes.co.uk/') br.open('http://www.thetimes.co.uk/')
@ -74,9 +79,9 @@ class TimesOnline(BasicNewsRecipe):
cover = None cover = None
return cover return cover
remove_tags = [{ remove_tags = [
'attrs': {'class': lambda x: x and 'is-hidden' in x.split()}, classes('Topics is-hidden Tooltip Toolbar Comments RelatedLinks'),
'name': ['object', 'link', 'iframe', 'base', 'meta', 'script']}, { {'name': ['object', 'link', 'iframe', 'base', 'meta', 'script']}, {
'attrs': { 'attrs': {
'class': [ 'class': [
'tools comments-parent', 'u-hide', 'Tooltip', 'tools comments-parent', 'u-hide', 'Tooltip',