| 1 |
import re |
| 2 |
|
| 3 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 4 |
|
| 5 |
|
| 6 |
class Dobreprogramy_pl(BasicNewsRecipe): |
| 7 |
title = 'Dobreprogramy.pl' |
| 8 |
__author__ = 'fenuks & Tomasz Długosz' |
| 9 |
__licence__ = 'GPL v3' |
| 10 |
category = 'IT' |
| 11 |
masthead_url = 'http://static.dpcdn.pl/css/Black/Images/header_logo_napis_fullVersion.png' |
| 12 |
cover_url = 'http://userlogos.org/files/logos/Karmody/dobreprogramy_01.png' |
| 13 |
description = 'Aktualności i blogi z dobreprogramy.pl' |
| 14 |
encoding = 'utf-8' |
| 15 |
index = 'http://www.dobreprogramy.pl/' |
| 16 |
no_stylesheets = True |
| 17 |
language = 'pl' |
| 18 |
extra_css = '.title {font-size:22px;}, h1 { font-size:130% }' |
| 19 |
oldest_article = 8 |
| 20 |
max_articles_per_feed = 100 |
| 21 |
remove_attrs = ['style', 'width', 'height'] |
| 22 |
preprocess_regexps = [ |
| 23 |
( |
| 24 |
re.compile(type('')(r'<div id="\S+360pmp4">Twoja przeglądarka nie obsługuje Flasha i HTML5 lub wyłączono obsługę JavaScript...</div>')), |
| 25 |
lambda match: '', |
| 26 |
) |
| 27 |
] |
| 28 |
keep_only_tags = [dict(name='h1'), dict(attrs={'class': ['entry single']}), dict(id='phContent_divArticle')] |
| 29 |
remove_tags = [ |
| 30 |
dict( |
| 31 |
attrs={ |
| 32 |
'class': [ |
| 33 |
'newsOptions', |
| 34 |
'noPrint', |
| 35 |
'komentarze', |
| 36 |
'tags font-heading-master', |
| 37 |
'social nested-grid grid-margin-px15-top clearfix no-mobile', |
| 38 |
'page-info text-h4 font-heading grid-margin-px15-top color-annotation clearfix', |
| 39 |
'series grid-margin-px30-top', |
| 40 |
] |
| 41 |
} |
| 42 |
), |
| 43 |
dict(id='komentarze'), |
| 44 |
dict(id='phContent_ctl02_sBreadcrumb'), |
| 45 |
dict(name='iframe'), |
| 46 |
] # noqa: E501 |
| 47 |
|
| 48 |
feeds = [('Aktualności', 'http://feeds.feedburner.com/dobreprogramy/Aktualnosci'), ('Blogi', 'http://feeds.feedburner.com/dobreprogramy/BlogCzytelnikow')] |
| 49 |
|
| 50 |
def preprocess_html(self, soup): |
| 51 |
for a in soup('a', href=True): |
| 52 |
if 'http://' not in a['href'] and 'https://' not in a['href']: |
| 53 |
a['href'] = self.index + a['href'] |
| 54 |
for r in soup.findAll('iframe'): |
| 55 |
r.parent.extract() |
| 56 |
return soup |
| 57 |
|
| 58 |
def postprocess_html(self, soup, first_fetch): |
| 59 |
for r in soup.findAll('span', text=''): |
| 60 |
if not r.string: |
| 61 |
r.extract() |
| 62 |
return soup |