| 1 |
""" |
| 2 |
spiegel.de |
| 3 |
""" |
| 4 |
|
| 5 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 6 |
|
| 7 |
|
| 8 |
class Spiegel_int(BasicNewsRecipe): |
| 9 |
title = 'Spiegel Online International' |
| 10 |
__author__ = 'unkn0wn' |
| 11 |
description = "Daily news, analysis and opinion from Europe's leading newsmagazine and Germany's top news Web site" |
| 12 |
oldest_article = 7 |
| 13 |
max_articles_per_feed = 100 |
| 14 |
language = 'en_DE' |
| 15 |
no_stylesheets = True |
| 16 |
use_embedded_content = False |
| 17 |
encoding = 'utf-8' |
| 18 |
publisher = 'SPIEGEL ONLINE GmbH' |
| 19 |
category = 'news, politics, Germany' |
| 20 |
publication_type = 'magazine' |
| 21 |
remove_empty_feeds = True |
| 22 |
remove_attributes = ['style', 'height', 'width'] |
| 23 |
ignore_duplicate_articles = {'url'} |
| 24 |
masthead_url = 'https://upload.wikimedia.org/wikipedia/commons/0/06/Logo-Der-Spiegel-de.png' |
| 25 |
|
| 26 |
conversion_options = {'comments': description, 'tags': category, 'language': language, 'publisher': publisher} |
| 27 |
|
| 28 |
def get_cover_url(self): |
| 29 |
soup = self.index_to_soup('https://www.spiegel.de/spiegel/print/') |
| 30 |
div = soup.find('div', attrs={'data-component': 'MagazineImage'}) |
| 31 |
citem = div.find('img', attrs={'data-src': True})['data-src'].replace('260', '800') |
| 32 |
return citem |
| 33 |
|
| 34 |
keep_only_tags = [dict(name='article')] |
| 35 |
|
| 36 |
remove_tags = [ |
| 37 |
dict(name='section', attrs={'data-app-hidden': True}), |
| 38 |
dict(name='div', attrs={'data-issue-context-hidden': True}), |
| 39 |
dict(name='div', attrs={'data-area': 'related_articles'}), |
| 40 |
dict(name='div', attrs={'data-component': 'HTMLEmbed'}), |
| 41 |
dict(name=['footer', 'button', 'svg']), |
| 42 |
] |
| 43 |
|
| 44 |
extra_css = ''' |
| 45 |
time{font-size:small;} |
| 46 |
[data-area="quote"]{text-align:center; color:#404040;} |
| 47 |
#fig-c{font-size:small; text-align:center;} |
| 48 |
''' |
| 49 |
|
| 50 |
feeds = [ |
| 51 |
('World', 'https://www.spiegel.de/international/world/index.rss'), |
| 52 |
('Europe', 'https://www.spiegel.de/international/europe/index.rss'), |
| 53 |
('Germany', 'https://www.spiegel.de/international/germany/index.rss'), |
| 54 |
('Business', 'https://www.spiegel.de/international/business/index.rss'), |
| 55 |
('Zeitgeist', 'https://www.spiegel.de/international/zeitgeist/index.rss'), |
| 56 |
('Tomorrow', 'https://www.spiegel.de/international/tomorrow/index.rss'), |
| 57 |
('Others', 'http://www.spiegel.de/international/index.rss'), |
| 58 |
] |
| 59 |
|
| 60 |
def preprocess_html(self, soup): |
| 61 |
for img in soup.findAll('img', attrs={'data-src': True}): |
| 62 |
img['src'] = img['data-src'] |
| 63 |
for fig in soup.findAll('figcaption'): |
| 64 |
fig['id'] = 'fig-c' |
| 65 |
return soup |