mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
52 lines
1.9 KiB
Bash
52 lines
1.9 KiB
Bash
from calibre.web.feeds.news import BasicNewsRecipe
|
|
|
|
|
|
class Bash_org_pl(BasicNewsRecipe):
|
|
title = u'Bash.org.pl'
|
|
__author__ = 'fenuks'
|
|
description = 'Bash.org.pl - zabawne cytaty z IRC'
|
|
category = 'funny quotations, humour'
|
|
language = 'pl'
|
|
cover_url = u'http://userlogos.org/files/logos/dzikiosiol/none_0.png'
|
|
max_articles_per_feed = 50
|
|
no_stylesheets = True
|
|
keep_only_tags = [dict(name='a', attrs={'class': 'qid click'}),
|
|
dict(name='div', attrs={'class': 'quote post-content post-body'})]
|
|
|
|
def latest_articles(self):
|
|
articles = []
|
|
soup = self.index_to_soup(u'http://bash.org.pl/latest/')
|
|
tags = soup.findAll('a', attrs={'class': 'qid click'})
|
|
for a in tags:
|
|
title = a.string
|
|
url = 'http://bash.org.pl' + a['href']
|
|
articles.append({'title': title,
|
|
'url': url,
|
|
'date': '',
|
|
'description': ''
|
|
})
|
|
return articles
|
|
|
|
def random_articles(self):
|
|
articles = []
|
|
for i in range(self.max_articles_per_feed):
|
|
soup = self.index_to_soup(u'http://bash.org.pl/random/')
|
|
url = soup.find('a', attrs={'class': 'qid click'})
|
|
title = ''
|
|
url = 'http://bash.org.pl/random/'
|
|
articles.append({'title': title,
|
|
'url': url,
|
|
'date': '',
|
|
'description': ''
|
|
})
|
|
return articles
|
|
|
|
def populate_article_metadata(self, article, soup, first):
|
|
article.title = soup.find(attrs={'class': 'qid click'}).string
|
|
|
|
def parse_index(self):
|
|
feeds = []
|
|
feeds.append((u"Najnowsze", self.latest_articles()))
|
|
feeds.append((u"Losowe", self.random_articles()))
|
|
return feeds
|