4
__copyright__ = u'2010-2013, Tomasz Dlugosz <tomek3d@gmail.com>'
10
from calibre.web.feeds.news import BasicNewsRecipe
11
from datetime import timedelta, date
13
class Fronda(BasicNewsRecipe):
15
publisher = u'Fronda.pl'
16
description = u'Portal po\u015bwi\u0119cony - Informacje'
18
__author__ = u'Tomasz D\u0142ugosz'
20
max_articles_per_feed = 100
21
use_embedded_content = False
26
.body {text-align:left;}
27
div#featured-image {font-style:italic; font-size:70%}
30
earliest_date = date.today() - timedelta(days=oldest_article)
32
def date_cut(self,datestr):
33
# eg. 5.11.2012, 12:07
34
timestamp = datestr.split(',')[0]
35
parts = timestamp.split('.')
36
art_date = date(int(parts[2]),int(parts[1]),int(parts[0]))
37
return True if art_date < self.earliest_date else False
39
def parse_index(self):
41
('ekonomia,4.html', 'Ekonomia'),
42
('filozofia,15.html', 'Filozofia'),
43
('historia,6.html', 'Historia'),
44
('kosciol,8.html', 'Kościół'),
45
('kultura,5.html', 'Kultura'),
46
('media,10.html', 'Media'),
47
('nauka,9.html', 'Nauka'),
48
('polityka,11.html', 'Polityka'),
49
('polska,12.html', 'Polska'),
50
('prolife,3.html', 'Prolife'),
51
('religia,7.html', 'Religia'),
52
('rodzina,13.html', 'Rodzina'),
53
('swiat,14.html', 'Świat'),
54
('wydarzenie,16.html', 'Wydarzenie')
59
for url, genName in genres:
61
soup = self.index_to_soup('http://www.fronda.pl/c/'+ url)
64
articles[genName] = []
65
for item in soup.findAll('li'):
66
article_h = item.find('h2')
69
article_date = self.tag_to_string(item.find('b'))
70
if self.date_cut(article_date):
72
article_a = article_h.find('a')
73
article_url = 'http://www.fronda.pl' + article_a['href']
74
article_title = self.tag_to_string(article_a)
75
articles[genName].append( { 'title' : article_title, 'url' : article_url, 'date' : article_date })
77
feeds.append((genName, articles[genName]))
81
dict(name='div', attrs={'class':'yui-g'})
85
dict(name='div', attrs={'class':['related-articles','button right','pagination','related-articles content']}),
86
dict(name='h3', attrs={'class':'block-header article comments'}),
87
dict(name='ul', attrs={'class':['comment-list','category','tag-list']}),
88
dict(name='p', attrs={'id':'comments-disclaimer'}),
89
dict(name='div', attrs={'style':'text-align: left; margin-bottom: 15px;'}),
90
dict(name='div', attrs={'style':'text-align: left; margin-top: 15px; margin-bottom: 30px;'}),
91
dict(name='div', attrs={'id':'comment-form'}),
92
dict(name='span', attrs={'class':'separator'})
95
preprocess_regexps = [
96
(re.compile(r'komentarzy: .*?</h6>', re.IGNORECASE | re.DOTALL | re.M ), lambda match: '</h6>')]