mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update La Republica. Fixes #904387 (Updated recipe for La Repubblica)
This commit is contained in:
parent
9a2f9517f7
commit
c14fd982e4
@ -1,13 +1,12 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__author__ = 'Lorenzo Vigentini, based on Darko Miletic, Gabriele Marini'
|
__author__ = 'Lorenzo Vigentini, based on Darko Miletic, Gabriele Marini'
|
||||||
__copyright__ = '2009-2011, Darko Miletic <darko.miletic at gmail.com>, Lorenzo Vigentini <l.vigentini at gmail.com>'
|
__copyright__ = '2009-2011, Darko Miletic <darko.miletic at gmail.com>, Lorenzo Vigentini <l.vigentini at gmail.com>'
|
||||||
description = 'Italian daily newspaper - v1.01 (04, January 2010); 16.05.2010 new version; 17.10.2011 new version'
|
description = 'Italian daily newspaper - v1.01 (04, January 2010); 16.05.2010 new version; 17.10.2011 new version; 14.12.2011 new version'
|
||||||
|
|
||||||
'''
|
'''
|
||||||
http://www.repubblica.it/
|
http://www.repubblica.it/
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import re
|
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
@ -25,27 +24,21 @@ class LaRepubblica(BasicNewsRecipe):
|
|||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
publication_type = 'newspaper'
|
publication_type = 'newspaper'
|
||||||
articles_are_obfuscated = True
|
articles_are_obfuscated = True
|
||||||
temp_files = []
|
temp_files = []
|
||||||
extra_css = """
|
extra_css = """
|
||||||
img{display: block}
|
img{display: block}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
remove_attributes = ['width','height','lang','xmlns:og','xmlns:fb']
|
remove_attributes = ['width','height','lang','xmlns:og','xmlns:fb']
|
||||||
|
|
||||||
preprocess_regexps = [
|
|
||||||
(re.compile(r'.*?<head>', re.DOTALL|re.IGNORECASE), lambda match: '<head>'),
|
|
||||||
(re.compile(r'<head>.*?<title>', re.DOTALL|re.IGNORECASE), lambda match: '<head><title>'),
|
|
||||||
(re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE), lambda match: '</title></head>')
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
link = BasicNewsRecipe.get_article_url(self, article)
|
link = BasicNewsRecipe.get_article_url(self, article)
|
||||||
if link and not '.repubblica.it/' in link:
|
if link and not '.repubblica.it/' in link:
|
||||||
link2 = article.get('id', article.get('guid', None))
|
link2 = article.get('id', article.get('guid', None))
|
||||||
if link2:
|
if link2:
|
||||||
link = link2
|
link = link2
|
||||||
return link.rpartition('?')[0]
|
return link.rpartition('?')[0]
|
||||||
|
|
||||||
def get_obfuscated_article(self, url):
|
def get_obfuscated_article(self, url):
|
||||||
count = 0
|
count = 0
|
||||||
@ -56,12 +49,12 @@ class LaRepubblica(BasicNewsRecipe):
|
|||||||
count = 10
|
count = 10
|
||||||
except:
|
except:
|
||||||
print "Retrying download..."
|
print "Retrying download..."
|
||||||
count += 1
|
count += 1
|
||||||
self.temp_files.append(PersistentTemporaryFile('_fa.html'))
|
self.temp_files.append(PersistentTemporaryFile('_fa.html'))
|
||||||
self.temp_files[-1].write(html)
|
self.temp_files[-1].write(html)
|
||||||
self.temp_files[-1].close()
|
self.temp_files[-1].close()
|
||||||
return self.temp_files[-1].name
|
return self.temp_files[-1].name
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(attrs={'class':'articolo'}),
|
dict(attrs={'class':'articolo'}),
|
||||||
dict(attrs={'class':'body-text'}),
|
dict(attrs={'class':'body-text'}),
|
||||||
@ -73,15 +66,15 @@ class LaRepubblica(BasicNewsRecipe):
|
|||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name=['object','link','meta','iframe','embed']),
|
dict(name=['object','link','meta','iframe','embed']),
|
||||||
dict(name='span',attrs={'class':'linkindice'}),
|
dict(name='span',attrs={'class':'linkindice'}),
|
||||||
dict(name='div', attrs={'class':'bottom-mobile'}),
|
dict(name='div', attrs={'class':['bottom-mobile','adv adv-middle-inline']}),
|
||||||
dict(name='div', attrs={'id':['rssdiv','blocco']}),
|
dict(name='div', attrs={'id':['rssdiv','blocco','fb-like-head']}),
|
||||||
dict(name='div', attrs={'class':'utility'}),
|
dict(name='div', attrs={'class':['utility','fb-like-button','archive-button']}),
|
||||||
dict(name='div', attrs={'class':'generalbox'}),
|
dict(name='div', attrs={'class':'generalbox'}),
|
||||||
dict(name='ul', attrs={'id':'hystory'})
|
dict(name='ul', attrs={'id':'hystory'})
|
||||||
]
|
]
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Rilievo', u'http://www.repubblica.it/rss/homepage/rss2.0.xml'),
|
(u'Homepage', u'http://www.repubblica.it/rss/homepage/rss2.0.xml'),
|
||||||
(u'Cronaca', u'http://www.repubblica.it/rss/cronaca/rss2.0.xml'),
|
(u'Cronaca', u'http://www.repubblica.it/rss/cronaca/rss2.0.xml'),
|
||||||
(u'Esteri', u'http://www.repubblica.it/rss/esteri/rss2.0.xml'),
|
(u'Esteri', u'http://www.repubblica.it/rss/esteri/rss2.0.xml'),
|
||||||
(u'Economia', u'http://www.repubblica.it/rss/economia/rss2.0.xml'),
|
(u'Economia', u'http://www.repubblica.it/rss/economia/rss2.0.xml'),
|
||||||
@ -105,8 +98,10 @@ class LaRepubblica(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.findAll(['hgroup','deresponsabilizzazione','per']):
|
for item in soup.findAll(['hgroup','deresponsabilizzazione','per']):
|
||||||
item.name = 'div'
|
item.name = 'div'
|
||||||
item.attrs = []
|
item.attrs = []
|
||||||
for item in soup.findAll(style=True):
|
for item in soup.findAll(style=True):
|
||||||
del item['style']
|
del item['style']
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
def preprocess_raw_html(self, raw, url):
|
||||||
|
return '<html><head>'+raw[raw.find('</head>'):]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user