| 1 |
from calibre.ebooks.BeautifulSoup import Comment |
| 2 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 3 |
|
| 4 |
# currently recipe is not working |
| 5 |
|
| 6 |
|
| 7 |
class PC_Foster(BasicNewsRecipe): |
| 8 |
title = 'PC Foster' |
| 9 |
oldest_article = 7 |
| 10 |
max_articles_per_feed = 100 |
| 11 |
__author__ = 'fenuks' |
| 12 |
description = 'Vortal technologiczny: testy, recenzje sprzętu komputerowego i telefonów, nowinki hardware, programy i gry dla Windows. Podkręcanie, modding i Overclocking.' # noqa: E501 |
| 13 |
category = 'IT' |
| 14 |
language = 'pl' |
| 15 |
masthead_url = 'http://pcfoster.pl/public/images/logo.png' |
| 16 |
cover_url = 'http://pcfoster.pl/public/images/logo.png' |
| 17 |
no_stylesheets = True |
| 18 |
remove_empty_feeds = True |
| 19 |
keep_only_tags = [dict(id=['news_details', 'review_details']), dict(attrs={'class': 'pager more_top'})] |
| 20 |
remove_tags = [dict(name='p', attrs={'class': 'right'})] |
| 21 |
feeds = [('G\u0142\xf3wny', 'http://pcfoster.pl/public/rss/main.xml')] |
| 22 |
|
| 23 |
def append_page(self, soup, appendtag): |
| 24 |
nexturl = appendtag.find(attrs={'alt': 'Następna strona'}) |
| 25 |
if nexturl: |
| 26 |
appendtag.find(attrs={'class': 'pager more_top'}).extract() |
| 27 |
while nexturl: |
| 28 |
nexturl = 'http://pcfoster.pl' + nexturl.parent['href'] |
| 29 |
soup2 = self.index_to_soup(nexturl) |
| 30 |
nexturl = soup2.find(attrs={'alt': 'Następna strona'}) |
| 31 |
pagetext = soup2.find(attrs={'class': 'content'}) |
| 32 |
pos = len(appendtag.contents) |
| 33 |
appendtag.insert(pos, pagetext) |
| 34 |
for r in appendtag.findAll(attrs={'class': 'review_content double'}): |
| 35 |
r.extract() |
| 36 |
comments = appendtag.findAll(text=lambda text: isinstance(text, Comment)) |
| 37 |
for comment in comments: |
| 38 |
comment.extract() |
| 39 |
|
| 40 |
def preprocess_html(self, soup): |
| 41 |
self.append_page(soup, soup.body) |
| 42 |
return soup |