Update Politico

Merge branch 'patch-1' of https://github.com/bobbysteel/calibre
This commit is contained in:
Kovid Goyal 2017-07-06 08:45:51 +05:30
commit cad3270764
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -35,8 +35,22 @@ class Politico(BasicNewsRecipe):
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + \ html2epub_options = 'publisher="' + publisher + '"\ncomments="' + \
description + '"\ntags="' + category + '"\nlinearize_tables=True' description + '"\ntags="' + category + '"\nlinearize_tables=True'
keep_only_tags = [
dict(name=['article']),
]
remove_tags = [ remove_tags = [
dict(name=['notags', 'embed', 'object', 'link', 'img']), dict(name=['notags', 'embed', 'aside', 'object', 'link', 'img', 'figure']),
dict(
attrs={'class': lambda x: x and 'story-tools' in x.split()}),
dict(
attrs={'class': lambda x: x and 'story-continued' in x.split()}),
dict(
attrs={'class': lambda x: x and 'story-supplement' in x.split()}),
dict(
attrs={'class': lambda x: x and 'story-share' in x.split()}),
dict(
attrs={'class': lambda x: x and 'suggested' in x.split()}),
] ]
extra_css = ''' extra_css = '''
@ -70,19 +84,8 @@ class Politico(BasicNewsRecipe):
del item['style'] del item['style']
return soup return soup
url_pat = re.compile(r'<a href="([^"]+print.*\.cfm[^"]+)"')
def postprocess_html(self, soup, first): def postprocess_html(self, soup, first):
for tag in soup.findAll(name=['table', 'tr', 'td']): for tag in soup.findAll(name=['table', 'tr', 'td']):
tag.name = 'div' tag.name = 'div'
return soup return soup
def print_version(self, url):
raw = self.index_to_soup(url, raw=True)
try:
url = self.url_pat.search(raw).group(1)
except:
traceback.print_exc()
url = None
return url