Debian Codegraph @

recipes/di.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=UTF-8
3
4 __license__ = 'GPL v3'
5 __author__ = 'Mori'
6 __version__ = 'v. 0.5'
7 '''
8 di.com.pl
9 '''
10
11 import re
12
13 from calibre.web.feeds.news import BasicNewsRecipe
14
15
16 class DziennikInternautowRecipe(BasicNewsRecipe):
17 __author__ = 'Mori'
18 language = 'pl'
19
20 title = 'Dziennik Internautów'
21 publisher = 'Dziennik Internaut\u00f3w Sp. z o.o.'
22 description = 'Internet w \u017cyciu i biznesie. Porady, wywiady, interwencje, bezpiecze\u0144stwo w Sieci, technologia.'
23
24 max_articles_per_feed = 100
25 oldest_article = 7
26 cover_url = 'http://di.com.pl/pic/logo_di_norm.gif'
27
28 no_stylesheets = True
29 remove_javascript = True
30 encoding = 'utf-8'
31
32 extra_css = '''
33 .fotodesc{font-size: 75%;}
34 .pub_data{font-size: 75%;}
35 .fotonews{clear: both; padding-top: 10px; padding-bottom: 10px;}
36 #pub_foto{font-size: 75%; float: left; padding-right: 10px;}
37 '''
38
39 feeds = [('Dziennik Internaut\u00f3w', 'http://feeds.feedburner.com/glowny-di')]
40
41 keep_only_tags = [dict(name='div', attrs={'id': 'pub_head'}), dict(name='div', attrs={'id': 'pub_content'})]
42
43 remove_tags = [
44 dict(name='div', attrs={'class': 'poradniki_context'}),
45 dict(name='div', attrs={'class': 'uniBox'}),
46 dict(name='object', attrs={}),
47 dict(name='h3', attrs={}),
48 dict(attrs={'class': 'twitter-share-button'}),
49 ]
50
51 preprocess_regexps = [
52 (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1])
53 for i in [
54 (r', <a href="http://di.com.pl/komentarze,.*?</div>', lambda match: '</div>'),
55 (r'<div class="fotonews".*?">', lambda match: '<div class="fotonews">'),
56 (r'http://di.com.pl/pic/photo/mini/', lambda match: 'http://di.com.pl/pic/photo/oryginal/'),
57 (r'\s*</', lambda match: '</'),
58 ]
59 ]
60
61 def skip_ad_pages(self, soup):
62 if 'Advertisement' in soup.title:
63 nexturl = soup.find('a')['href']
64 return self.index_to_soup(nexturl, raw=True)