Update Hola

This commit is contained in:
Kovid Goyal 2016-07-29 11:00:39 +05:30
parent 25e60aa62a
commit 643977ffa6

View File

@ -1,19 +1,20 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
# vim:fileencoding=UTF-8
__license__ = 'GPL v3'
__copyright__ = '30 June 2012, desUBIKado'
__author__ = 'desUBIKado'
__description__ = 'Diario de actualidad, moda y belleza'
__version__ = 'v0.01'
__date__ = '30, June 2012'
__version__ = 'v0.03'
__date__ = '28, Jul 2016'
'''
http://www.hola.com/
'''
import re
from calibre.web.feeds.news import BasicNewsRecipe
class hola_es(BasicNewsRecipe):
__author__ = 'desUBIKado'
author = 'desUBIKado'
description = 'Diario de actualidad, moda y belleza'
title = u'¡Hola!'
publisher = 'Hola S.L.'
@ -43,23 +44,42 @@ class hola_es(BasicNewsRecipe):
keep_only_tags = [dict(name='div', attrs={'id':['cuerpo','com']})]
keep_only_tags = [dict(name='article', attrs={'class':['body col-md-8 col-xs-12']})]
remove_tags = [dict(name='div', attrs={'id':['relacionadas','slide-enlaces-patrocinados','comentarios']}),
dict(name='div', attrs={'class':['slide-enlaces-patricinados-tit','compartir']})
remove_tags = [dict(name='div', attrs={'class':['comments','news-share','sponsored-news']}),
dict(name='div', attrs={'itemprop':['logo']}),
dict(name='span', attrs={'class':['hidden']}),
dict(name='p', attrs={'class':['hidden']}),
dict(name='section', attrs={'class':['news-tags']})
]
remove_tags_after = dict(name='div' , attrs={'id':'comentarios'})
remove_tags_after = dict(name='div' , attrs={'class':'comments'})
# <span>VER GALERÍA<i data-icon="1" class="icon"></i></span>
preprocess_regexps = [
# Quitar VER GALERÍA
(re.compile(r'<span>VER GALER', re.DOTALL|re.IGNORECASE), lambda m: '<!--'),
(re.compile(r'class="icon"></i></span>', re.DOTALL|re.IGNORECASE), lambda m: '-->'),
# Quitar enlaces varios
(re.compile(r'<p><a href="http://www.hola.com', re.DOTALL|re.IGNORECASE), lambda m: '<!--'),
(re.compile(r'<p style="text-align: center;">', re.DOTALL|re.IGNORECASE), lambda m: '<!--'),
(re.compile(r'<p style="line-height: 20.8px;"><a href="http://www.hola.com', re.DOTALL|re.IGNORECASE), lambda m: '<!--'),
(re.compile(r'</strong></a></p>', re.DOTALL|re.IGNORECASE), lambda m: '-->')
]
# Recuperamos la portada de papel (la imagen 520 tiene mayor resolucion)
# http://www.hola.com/imagenes/revista/3727/portada-revista-hola-520.jpg
def get_cover_url(self):
index = 'http://www.hola.com/abono/ediciondigital/'
soup = self.index_to_soup(index)
for image in soup.findAll('img',src=True):
if image['src'].endswith('portada-revista-hola-520.jpg'):
return 'http://www.hola.com/' + image['src']
return 'http://www.hola.com' + image['src']
return None