Debian Codegraph @

recipes/der_standard.recipe

raw
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 from __future__ import absolute_import, division, print_function, unicode_literals
4
5 __license__ = 'GPL v3'
6 __copyright__ = '2009, Gerhard Aigner <gerhard.aigner at gmail.com>'
7
8 ''' http://www.derstandard.at - Austrian Newspaper '''
9
10 from calibre.web.feeds.news import BasicNewsRecipe
11
12
13 def classes(classes):
14 q = frozenset(classes.split(' '))
15 return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
16
17
18 class DerStandardRecipe(BasicNewsRecipe):
19 title = 'derStandard'
20 __author__ = 'Gerhard Aigner and Sujata Raman and Marcel Jira and Peter Reschenhofer'
21 description = 'Nachrichten aus Österreich'
22 publisher = 'derStandard.at'
23 category = 'news, politics, nachrichten, Austria'
24 use_embedded_content = False
25 remove_empty_feeds = True
26 no_stylesheets = True
27 encoding = 'utf-8'
28 language = 'de_AT'
29
30 oldest_article = 1
31 max_articles_per_feed = 100
32 ignore_duplicate_articles = {'title', 'url'}
33
34 masthead_url = 'http://images.derstandard.at/2012/06/19/derStandardat_1417x274.gif'
35
36 feeds = [
37 ('International', 'https://www.derstandard.at/rss/international'),
38 ('Inland', 'https://www.derstandard.at/rss/inland'),
39 ('Wirtschaft', 'https://www.derstandard.at/rss/wirtschaft'),
40 ('Web', 'https://www.derstandard.at/rss/web'),
41 ('Sport', 'https://derStandard.at/rss/Sport'),
42 ('Panorama', 'https://derStandard.at/rss/Panorama'),
43 ('Etat', 'https://derStandard.at/rss/Etat'),
44 ('Kultur', 'https://derStandard.at/rss/Kultur'),
45 ('Wissenschaft', 'https://derStandard.at/rss/Wissenschaft'),
46 ('Gesundheit', 'https://derStandard.at/rss/Gesundheit'),
47 # (u'Bildung', u'https://derStandard.at/rss/Bildung'),
48 # (u'Meinung', u'https://derStandard.at/rss/Meinung'),
49 ('Lifestyle', 'https://derStandard.at/rss/Lifestyle'),
50 # (u'Reisen', u'https://derStandard.at/rss/Reisen'),
51 # (u'Familie', u'https://derstandard.at/rss/Familie'),
52 # (u'Meinung', u'https://derStandard.at/rss/Meinung'),
53 # (u'User', u'https://derStandard.at/rss/User'),
54 ('Karriere', 'https://derStandard.at/rss/Karriere'),
55 # (u'Immobilien', u'https://derstandard.at/rss/Immobilien'),
56 # (u'Automobil', u'https://derstandard.at/rss/Automobil'),
57 ('dieStandard', 'https://derStandard.at/rss/diestandard'),
58 ('Newsroom', 'https://www.derstandard.at/rss'),
59 ]
60
61 def get_browser(self):
62 br = BasicNewsRecipe.get_browser(self)
63 br.set_simple_cookie('DSGVO_Check', '', '.derstandard.at')
64 headers = {
65 'X-Requested-With': 'XMLHttpRequest',
66 'Content-Type': 'application/json; charset=UTF-8',
67 'DNT': '1',
68 'Pragma': 'no-cache',
69 'Cache-Control': 'no-cache',
70 }
71 import mechanize
72
73 req = mechanize.Request(url='https://apps.derstandard.at/privacyprotection/api/agree', data=None, headers=headers, method='POST')
74 br.open(req)
75 return br
76
77 keep_only_tags = [
78 classes('article-header article-body article-origins article-subtitle article-pubdate'),
79 ]
80
81 remove_tags = [
82 dict(name=['link', 'iframe', 'style', 'hr']),
83 dict(attrs={'class': ['lookup-links', 'media-list']}),
84 dict(name='form', attrs={'name': 'sitesearch'}),
85 dict(name='div', attrs={'class': ['socialsharing', 'block video', 'blog-browsing section', 'diashow', 'supplemental']}),
86 dict(name='div', attrs={'id': 'highlighted'}),
87 ]
88
89 remove_attributes = ['width', 'height']