calibre/recipes/spektrum.recipe
2019-02-05 09:20:46 +05:30

71 lines
2.2 KiB
Python

#!/usr/bin/env python2
##
# Written: October 2012 (new coding)
# Version: 9.0
# Last update: 2019-02-02
##
__license__ = 'GPL v3'
__copyright__ = ''
'''
Fetch RSS-Feeds spektrum.de
'''
def classes(classes):
q = frozenset(classes.split(' '))
return dict(
attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}
)
from calibre.web.feeds.recipes import BasicNewsRecipe
class Spektrum(BasicNewsRecipe):
title = u'Spektrum der Wissenschaft'
__author__ = 'Armin Geller, Bratzzo, Rainer Zenz' # Update AGE 2014-02-25, UDe 2019-02-02
description = u'German online portal of Spektrum der Wissenschaft'
publisher = 'Spektrum der Wissenschaft Verlagsgesellschaft mbH'
category = 'science news, Germany'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
language = 'de'
encoding = 'utf8'
ignore_duplicate_articles = {'title'}
cover_url = 'https://www.spektrum.de/js_css/sde/assets/img/svg/sdw_dark.svg'
masthead_url = 'http://www.spektrum.de/fm/861/spektrum.de.png'
feeds = [
(
u'Spektrum.de',
u'http://www.spektrum.de/alias/rss/spektrum-de-rss-feed/996406'
),
# (u'Spektrum der Wissenschaft', u'http://www.spektrum.de/alias/rss/spektrum-der-wissenschaft-rss-feed/982623'),
# (u'Gehirn & Geist', u'http://www.spektrum.de/alias/rss/gehirn-geist-rss-feed/982626'),
(
u'Sterne und Weltraum',
u'http://www.spektrum.de/alias/rss/sterne-und-weltraum-rss-feed/865248'
),
# (u'Meistgelesene Artikel',u'http://www.spektrum.de/alias/rss/spektrum-de-meistgelesene-artikel/1224665'), # AGe 2014-08-21 new
]
keep_only_tags = [
dict(name='article', attrs={'class': 'content'}),
]
remove_tags = [
classes('hide-for-print content__meta content__author content__video'),
dict(name='div', attrs={'role': 'navigation'}),
dict(name='span', attrs={'class': 'sr-only'}),
]
def preprocess_html(self, soup, *a):
for img in soup.findAll('img', attrs={'data-src': True}):
img['src'] = img['data-src']
return soup