From 3d1ef6e56499bd24cbca3fb263dfa9580d5b3f9a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 3 Feb 2010 16:14:25 -0700 Subject: [PATCH] Fix #4786 (Updated recipe for Pagina 12) --- resources/recipes/pagina12.recipe | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/resources/recipes/pagina12.recipe b/resources/recipes/pagina12.recipe index 2fb433dc82..c9801cb359 100644 --- a/resources/recipes/pagina12.recipe +++ b/resources/recipes/pagina12.recipe @@ -5,9 +5,10 @@ __copyright__ = '2008-2010, Darko Miletic ' pagina12.com.ar ''' -import time +import re, time from calibre import strftime from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag class Pagina12(BasicNewsRecipe): title = 'Pagina - 12' @@ -22,7 +23,8 @@ class Pagina12(BasicNewsRecipe): use_embedded_content = False language = 'es' remove_empty_feeds = True - extra_css = ' body{font-family: sans-serif} ' + masthead_url = 'http://www.pagina12.com.ar/commons/imgs/logo-home.gif' + extra_css = ' body{font-family: Arial,Helvetica,sans-serif } h2{color: #028CCD} img{margin-bottom: 0.4em} .epigrafe{font-size: x-small; background-color: #EBEAE5; color: #565144 } .intro{font-size: 1.1em} ' conversion_options = { 'comment' : description @@ -32,7 +34,7 @@ class Pagina12(BasicNewsRecipe): } remove_tags = [dict(name='div', attrs={'id':['volver','logo','logo_suple','fin','permalink']})] - + feeds = [ (u'Edicion impresa', u'http://www.pagina12.com.ar/diario/rss/principal.xml' ) @@ -52,7 +54,11 @@ class Pagina12(BasicNewsRecipe): return url.replace('http://www.pagina12.com.ar/','http://www.pagina12.com.ar/imprimir/') def get_cover_url(self): - imgnames = ['tapan.jpg','tapagn.jpg','tapan_gr.jpg','tapagn.jpg','tapagn.jpg','tapan.jpg','tapagn.jpg'] - weekday = time.localtime().tm_wday - return strftime('http://www.pagina12.com.ar/fotos/%Y%m%d/diario/') + imgnames[weekday] - + rawc = self.index_to_soup('http://www.pagina12.com.ar/diario/principal/diario/index.html',True) + rawc2 = re.sub(r'PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN','PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"',rawc) + soup = BeautifulSoup(rawc2,fromEncoding=self.encoding,smartQuotesTo=None) + for image in soup.findAll('img',alt=True): + if image['alt'].startswith('Tapa de la fecha'): + return image['src'] + return None + \ No newline at end of file