| 1 |
__license__ = 'GPL v3' |
| 2 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 3 |
|
| 4 |
|
| 5 |
class LinuxPortal(BasicNewsRecipe): |
| 6 |
title = 'LinuxPortal' |
| 7 |
__author__ = 'fenuks' |
| 8 |
description = 'Na LinuxPortal.pl znajdziesz wiadomości o systemie Linux, open source oraz Androidzie.' |
| 9 |
category = 'it' |
| 10 |
language = 'pl' |
| 11 |
cover_url = 'http://www.linuxportal.pl/templates/css/loga/Linuxportal.gif' |
| 12 |
masthead_url = 'http://www.linuxportal.pl/templates/css/loga/Linuxportal.gif' |
| 13 |
use_embedded_content = False |
| 14 |
oldest_article = 7 |
| 15 |
max_articles_per_feed = 20 |
| 16 |
no_stylesheets = True |
| 17 |
remove_empty_feeds = True |
| 18 |
remove_javascript = True |
| 19 |
remove_attributes = ['style', 'font'] |
| 20 |
ignore_duplicate_articles = {'title', 'url'} |
| 21 |
auto_cleanup = True |
| 22 |
|
| 23 |
def parse_index(self): |
| 24 |
feeds = [] |
| 25 |
feeds.append(('Wszystkie wiadomości', self.get_articles('http://www.linuxportal.pl/news/wszystkie'))) |
| 26 |
return feeds |
| 27 |
|
| 28 |
def get_articles(self, url): |
| 29 |
articles = [] |
| 30 |
blacklist = { |
| 31 |
'dobreprogramy.pl', |
| 32 |
'osworld.pl', |
| 33 |
'osnews.pl', |
| 34 |
} |
| 35 |
nexturl = url |
| 36 |
counter = 0 |
| 37 |
skip = False |
| 38 |
while counter < self.max_articles_per_feed: |
| 39 |
soup = self.index_to_soup(nexturl) |
| 40 |
nexturl = soup.find(attrs={'title': 'Starsze wyniki'})['href'] |
| 41 |
for tag in soup.findAll(attrs={'class': 'lista_wizyt_kol_tytul_news'}): |
| 42 |
title = tag.h2.a.string |
| 43 |
url = tag.find(attrs={'class': 'linkzrodlo'})['href'] |
| 44 |
date = '' |
| 45 |
for item in blacklist: |
| 46 |
if item in url: |
| 47 |
counter -= 1 |
| 48 |
skip = True |
| 49 |
break |
| 50 |
if skip: |
| 51 |
skip = False |
| 52 |
continue |
| 53 |
|
| 54 |
articles.append({'title': title, 'url': url, 'date': date, 'description': ''}) |
| 55 |
counter += 1 |
| 56 |
return articles |