Fix #4786 (Updated recipe for Pagina 12)

This commit is contained in:
Kovid Goyal 2010-02-03 16:14:25 -07:00
parent 4ecab6bc9e
commit 3d1ef6e564

View File

@ -5,9 +5,10 @@ __copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
pagina12.com.ar pagina12.com.ar
''' '''
import time import re, time
from calibre import strftime from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag
class Pagina12(BasicNewsRecipe): class Pagina12(BasicNewsRecipe):
title = 'Pagina - 12' title = 'Pagina - 12'
@ -22,7 +23,8 @@ class Pagina12(BasicNewsRecipe):
use_embedded_content = False use_embedded_content = False
language = 'es' language = 'es'
remove_empty_feeds = True 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 = { conversion_options = {
'comment' : description 'comment' : description
@ -52,7 +54,11 @@ class Pagina12(BasicNewsRecipe):
return url.replace('http://www.pagina12.com.ar/','http://www.pagina12.com.ar/imprimir/') return url.replace('http://www.pagina12.com.ar/','http://www.pagina12.com.ar/imprimir/')
def get_cover_url(self): def get_cover_url(self):
imgnames = ['tapan.jpg','tapagn.jpg','tapan_gr.jpg','tapagn.jpg','tapagn.jpg','tapan.jpg','tapagn.jpg'] rawc = self.index_to_soup('http://www.pagina12.com.ar/diario/principal/diario/index.html',True)
weekday = time.localtime().tm_wday rawc2 = re.sub(r'PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN','PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"',rawc)
return strftime('http://www.pagina12.com.ar/fotos/%Y%m%d/diario/') + imgnames[weekday] 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