calibre/recipes/freenature.recipe
Kovid Goyal 3e09d4f456
Update Nature News
Fixes #1936786 [Error when downloading recipe](https://bugs.launchpad.net/calibre/+bug/1936786)
2021-07-27 12:09:18 +05:30

38 lines
1.0 KiB
Python

from calibre.web.feeds.news import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
class NatureNews(BasicNewsRecipe):
title = u'Nature News'
language = 'en'
__author__ = 'Kovid Goyal'
oldest_article = 31 # days
remove_empty_feeds = True
max_articles_per_feed = 50
no_stylesheets = True
use_embedded_content = False
remove_javascript = True
keep_only_tags = [
classes('container-type-article'),
]
remove_tags = [
dict(id='related-articles'),
classes('u-hide-print hide-print visually-hidden'),
dict(name=['meta', 'link', 'source']),
]
# News and comments
feeds = [(u'Nature News', 'http://feeds.nature.com/nature/rss/current')]
def preprocess_html(self, soup):
for img in soup.findAll('img', src=lambda x: x and x.startswith('//')):
img['src'] = 'https:' + img['src']
print(img)
return soup