Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 08-18-2014, 07:31 AM   #1
desUBIKado
Member
desUBIKado began at the beginning.
 
Posts: 22
Karma: 12
Join Date: Feb 2009
Location: Zaragoza, Spain
Device: prs-505, iliad
heraldo.es updated [ES]

Hi there:

I bring a new version of this recipe. The last version had formatting problems.

Regards.

Spoiler:

Code:
#!/usr/bin/env  python
__license__     = 'GPL v3'
__copyright__   = '04 December 2010, desUBIKado'
__author__      = 'desUBIKado'
__description__ = 'Daily newspaper from Aragon'
__version__     = 'v0.07'
__date__        = '17, August 2014'
'''
http://www.heraldo.es/
'''

import time
import re
from calibre.web.feeds.news import BasicNewsRecipe

class heraldo(BasicNewsRecipe):
    author        = 'desUBIKado'
    description   = 'Daily newspaper from Aragon'
    title          = u'Heraldo de Aragon'
    publisher      = 'Grupo Heraldo'
    category       = 'News, politics, culture, economy, general interest'
    language       = 'es'
    timefmt        = '[%a, %d %b, %Y]'
    oldest_article = 2
    delay          = 1
    max_articles_per_feed = 100
    use_embedded_content  = False
    masthead_url          = 'http://www.heraldo.es/MODULOS/global/publico/interfaces/img/logo-Heraldo.png'
    remove_empty_feeds    = True
    remove_javascript = True
    no_stylesheets = True
    

    feeds          = [
                        (u'Noticias', u'http://www.heraldo.es/index.php/mod.portadas/mem.rss')
                     ]

          
    keep_only_tags     = [dict(name='div', attrs={'class':['row-f2 brd-row-f4 bck-row-f1-f1 padd-t padd-btt con n-marg-btt']}),
			  dict(name='div', attrs={'id':['dts','com']}),
			  dict(name='img', attrs={'class':['lazy']})]			  			  
	  	
    remove_tags        = [dict(name='a', attrs={'class':['com flo-r','enl-if','enl-df','next_com']}),
                          dict(name='div', attrs={'class':['brb-b-s con marg-btt','cnt-rel con','col5-f1','tit txt-wh f-s con','con cont-top ','col5-f1 flo-l','cnt-rel brr','caj_part con','caj_topic con']}),
			  dict(name='div', attrs={'id':['cont-Top-8760','caj-pub','8760-cpt1','caj_topic con','slider-oferplan','cont-Top-']}),
                          dict(name='form', attrs={'class':'form'}), 
			  dict(name='ul', attrs={'class':['tabs-nav','men_nav con hg_2n','lst-not-f2 con  ']}),
			  dict(name='span', attrs={'class':['flo-r']}),
                          dict(name='ul', attrs={'id':['cont-tags','pag-1','pag-cnt-I-']})]
  	

    remove_tags_before = dict(name='div' , attrs={'id':'dts'})
    remove_tags_after  = dict(name='div' , attrs={'id':'com'})

    def get_cover_url(self):
       cover = None
       st = time.localtime()
       year = str(st.tm_year)
       month = "%.2d" % st.tm_mon
       day = "%.2d" % st.tm_mday                
		#http://oldorigin-www.heraldo.es/20101211/primeras/portada_aragon.pdf
       cover='http://oldorigin-www.heraldo.es/'+ year +  month + day +'/primeras/portada_aragon.pdf'
       br = BasicNewsRecipe.get_browser(self)
       try:
           br.open(cover)
       except:
           self.log("\nPortada no disponible")
           cover ='http://www.heraldo.es/MODULOS/global/publico/interfaces/img/logo-Heraldo.png'
       return cover
    

    extra_css = '''                    
                    h1 {font-family:Arial,Helvetica,sans-serif; font-weight:bold;font-size:28px;}   
                    h2 {font-family:georgia,serif; font-style:italic; font-weight:normal;font-size:22px;color:#4D4D4D;}             
                    .ladillo {font-family:georgia,serif; font-weight:bold;font-size:18px;}                      
		    .firm, .sp, .fech, ".com flo-r" {font-family:Arial,Helvetica,sans-serif; font-weight:normal;font-size:12px;}                                   
                    img{margin-bottom: 0.4em}
                '''      

    preprocess_regexps = [     
    
# Para separar los comentarios con una linea en blanco
                           (re.compile(r'<div class="tit-f2">', re.DOTALL|re.IGNORECASE), lambda match: '<br /><br /><div class="tit-f2">'),
                           (re.compile(r'<div id="com"', re.DOTALL|re.IGNORECASE), lambda match: '<br><div id="com"'),
                           
# Para ver las imágenes de las noticias
                           (re.compile(r'<img class="lazy" data-original="', re.DOTALL|re.IGNORECASE), lambda match: '<img src="http://www.heraldo.es')

                         ]
desUBIKado is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updated recipe: Heraldo de Aragon [ES] desUBIKado Recipes 0 12-02-2013 02:33 PM
Kindle 4 NT - Updated Screen-saver code, updated hack bmsleight Amazon Kindle 2 10-07-2012 03:57 PM
Updated recipe: Heraldo de Aragon [ES] desUBIKado Recipes 0 06-30-2012 09:58 AM
Was I updated? Kumabjorn Amazon Kindle 2 10-29-2010 07:08 AM
updated metadata=updated file? jomaweb Calibre 13 01-28-2010 08:12 PM


All times are GMT -4. The time now is 01:45 AM.


MobileRead.com is a privately owned, operated and funded community.