mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update horizons.recipe
remove empty p tags
This commit is contained in:
parent
d72d746c1a
commit
1526d0d06f
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
'''
|
"""
|
||||||
https://www.cirsd.org/en/horizons
|
https://www.cirsd.org/en/horizons
|
||||||
'''
|
"""
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||||
|
|
||||||
@ -10,10 +10,12 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
|
|||||||
class horizons(BasicNewsRecipe):
|
class horizons(BasicNewsRecipe):
|
||||||
title = 'Horizons'
|
title = 'Horizons'
|
||||||
__author__ = 'unkn0wn'
|
__author__ = 'unkn0wn'
|
||||||
description = (' Horizons – Journal of International Relations and Sustainable Development.'
|
description = (
|
||||||
|
' Horizons – Journal of International Relations and Sustainable Development.'
|
||||||
' Horizons serves as a high-level platform for influential voices from around the world to'
|
' Horizons serves as a high-level platform for influential voices from around the world to'
|
||||||
' provide informed analysis and conduct reasoned exchanges on the full spectrum of issues'
|
' provide informed analysis and conduct reasoned exchanges on the full spectrum of issues'
|
||||||
' that shape international developments.')
|
' that shape international developments.'
|
||||||
|
)
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
@ -22,13 +24,12 @@ class horizons(BasicNewsRecipe):
|
|||||||
masthead_url = 'https://www.cirsd.org/bundles/olpublic/images/horizons-logo.jpg'
|
masthead_url = 'https://www.cirsd.org/bundles/olpublic/images/horizons-logo.jpg'
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
extra_css = 'em{color:#404040;}'
|
extra_css = 'em{color:#404040;}'
|
||||||
|
simultaneous_downloads = 1
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [dict(name='div', attrs={'class': 'article'})]
|
||||||
dict(name='div', attrs={'class':'article'})
|
|
||||||
]
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
classes('back-link'),
|
classes('back-link'),
|
||||||
dict(name='div', attrs={'class':'single-post-footer'})
|
dict(name='div', attrs={'class': 'single-post-footer'}),
|
||||||
]
|
]
|
||||||
|
|
||||||
recipe_specific_options = {
|
recipe_specific_options = {
|
||||||
@ -38,6 +39,9 @@ class horizons(BasicNewsRecipe):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def preprocess_raw_html(self, raw, *a):
|
||||||
|
return raw.replace('<p> </p>', '')
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
return BasicNewsRecipe.get_browser(self, verify_ssl_certificates=False)
|
return BasicNewsRecipe.get_browser(self, verify_ssl_certificates=False)
|
||||||
|
|
||||||
@ -47,7 +51,7 @@ class horizons(BasicNewsRecipe):
|
|||||||
url = d
|
url = d
|
||||||
else:
|
else:
|
||||||
soup = self.index_to_soup('https://www.cirsd.org/en/horizons')
|
soup = self.index_to_soup('https://www.cirsd.org/en/horizons')
|
||||||
a = soup.findAll('a', href=True, attrs={'class':'horizon-gallery-box'})[0] # use 1 for previous edition
|
a = soup.find('a', href=True, attrs={'class':'horizon-gallery-box'})
|
||||||
url = a['href']
|
url = a['href']
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
url = 'https://www.cirsd.org' + url
|
url = 'https://www.cirsd.org' + url
|
||||||
@ -74,10 +78,7 @@ class horizons(BasicNewsRecipe):
|
|||||||
if span:
|
if span:
|
||||||
desc = self.tag_to_string(span).strip()
|
desc = self.tag_to_string(span).strip()
|
||||||
self.log('\t', title, '\n\t', desc, '\n\t\t', url)
|
self.log('\t', title, '\n\t', desc, '\n\t\t', url)
|
||||||
articles.append({
|
articles.append({'title': title, 'url': url, 'description': desc})
|
||||||
'title': title,
|
|
||||||
'url': url,
|
|
||||||
'description': desc})
|
|
||||||
if articles:
|
if articles:
|
||||||
feeds.append((secname, articles))
|
feeds.append((secname, articles))
|
||||||
return feeds
|
return feeds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user