mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
...
This commit is contained in:
parent
a9b701d685
commit
5cbbc9b998
@ -25,12 +25,12 @@ 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 = [
|
preprocess_regexps = [
|
||||||
@ -38,14 +38,14 @@ class LaRepubblica(BasicNewsRecipe):
|
|||||||
(re.compile(r'<head>.*?<title>', re.DOTALL|re.IGNORECASE), lambda match: '<head><title>'),
|
(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>')
|
(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 +56,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'}),
|
||||||
@ -105,8 +105,8 @@ 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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user