| 1 |
from calibre.web.feeds.news import BasicNewsRecipe, classes |
| 2 |
|
| 3 |
|
| 4 |
class DeutscheWelle_bs(BasicNewsRecipe): |
| 5 |
title = 'Deutsche Welle' |
| 6 |
__author__ = 'unkn0wn' |
| 7 |
description = 'Vijesti iz Njemacke i svijeta' |
| 8 |
publisher = 'Deutsche Welle' |
| 9 |
category = 'news, politics, Germany' |
| 10 |
oldest_article = 2 |
| 11 |
max_articles_per_feed = 100 |
| 12 |
use_embedded_content = False |
| 13 |
no_stylesheets = True |
| 14 |
language = 'bs' |
| 15 |
publication_type = 'newsportal' |
| 16 |
remove_empty_feeds = True |
| 17 |
remove_javascript = True |
| 18 |
masthead_url = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif' |
| 19 |
|
| 20 |
ignore_duplicate_articles = {'title', 'url'} |
| 21 |
remove_attributes = ['height', 'width', 'style'] |
| 22 |
|
| 23 |
keep_only_tags = [dict(name='article')] |
| 24 |
|
| 25 |
recipe_specific_options = { |
| 26 |
'days': { |
| 27 |
'short': 'Oldest article to download from this news source. In days ', |
| 28 |
'long': 'For example, 0.5, gives you articles from the past 12 hours', |
| 29 |
'default': str(oldest_article), |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
def __init__(self, *args, **kwargs): |
| 34 |
BasicNewsRecipe.__init__(self, *args, **kwargs) |
| 35 |
d = self.recipe_specific_options.get('days') |
| 36 |
if d and isinstance(d, str): |
| 37 |
self.oldest_article = float(d) |
| 38 |
|
| 39 |
remove_tags = [dict(name=['footer', 'source']), dict(attrs={'data-tracking-name': 'sharing-icons-inline'}), classes('kicker advertisement vjs-wrapper')] |
| 40 |
|
| 41 |
feeds = [ |
| 42 |
('Politika', 'http://rss.dw-world.de/rdf/rss-bos-pol'), |
| 43 |
('Evropa', 'http://rss.dw-world.de/rdf/rss-bos-eu'), |
| 44 |
('Kiosk', 'http://rss.dw-world.de/rdf/rss-bos-eu'), |
| 45 |
('Ekonomija i Nuka', 'http://rss.dw-world.de/rdf/rss-bos-eco'), |
| 46 |
('Kultura', 'http://rss.dw-world.de/rdf/rss-bos-cul'), |
| 47 |
('Sport', 'http://rss.dw-world.de/rdf/rss-bos-sp'), |
| 48 |
] |
| 49 |
|
| 50 |
def preprocess_html(self, soup): |
| 51 |
for img in soup.findAll('img', srcset=True): |
| 52 |
img['src'] = img['srcset'].split()[6] |
| 53 |
return soup |