mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #3732 (Built-in "Politico" recipe is broken)
This commit is contained in:
parent
9eacbc9d8c
commit
c1c3a6555f
@ -6,9 +6,12 @@ __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
|||||||
politico.com
|
politico.com
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import re, traceback
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class Politico(BasicNewsRecipe):
|
class Politico(BasicNewsRecipe):
|
||||||
|
|
||||||
title = 'Politico'
|
title = 'Politico'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = 'Political news from USA'
|
description = 'Political news from USA'
|
||||||
@ -55,13 +58,13 @@ class Politico(BasicNewsRecipe):
|
|||||||
del item['style']
|
del item['style']
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def print_url(self, soup, default):
|
url_pat = re.compile(r'<a href="([^"]+printstory\.cfm[^"]+)"')
|
||||||
printtags = soup.findAll('a',href=True)
|
|
||||||
for printtag in printtags:
|
|
||||||
if printtag.string == "Print":
|
|
||||||
return printtag['href']
|
|
||||||
return default
|
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
soup = self.index_to_soup(url)
|
raw = self.index_to_soup(url, raw=True)
|
||||||
return self.print_url(soup, None)
|
try:
|
||||||
|
url = self.url_pat.search(raw).group(1)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
url = None
|
||||||
|
return url
|
||||||
|
Loading…
x
Reference in New Issue
Block a user