Debian Codegraph @

recipes/habr_ru.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3
4 from calibre.web.feeds.news import BasicNewsRecipe
5
6
7 class Habr(BasicNewsRecipe):
8 title = '\u0425\u0430\u0431\u0440'
9 __author__ = 'bugmen00t'
10 description = '\u041d\u0430 \u200b\u0425\u0430\u0431\u0440\u0435 \u200b\u0434\u0443\u043c\u0430\u044e\u0449\u0438\u0435 \u200b\u043b\u044e\u0434\u0438 \u200b\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u200b\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u200b\u200b\u043e\u043f\u044b\u0442\u043e\u043c. \u200b\u200b\u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u200b\u200b\u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u200b\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u200b\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u200b\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0441\u0442\u0430\u043c, \u200b\u200b\u0430\u0434\u043c\u0438\u043d\u0430\u043c \u200b\u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u0449\u0438\u043a\u0430\u043c, \u200b\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u200b\u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0430\u043c, \u200b\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c \u200b\u0432\u044b\u0441\u0448\u0435\u0433\u043e \u200b\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u200b\u0437\u0432\u0435\u043d\u0430, \u200b\u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430\u043c \u200b\u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u200b\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u200b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u200b\u0444\u0438\u0440\u043c, \u200b\u0430 \u0442\u0430\u043a\u0436\u0435 \u200b\u0432\u0441\u0435\u043c \u200b\u0442\u0435\u043c, \u200b\u0434\u043b\u044f \u043a\u043e\u0433\u043e \u200bIT \u2014 \u200b\u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u200b\u0434\u0432\u0435 \u0431\u0443\u043a\u0432\u044b \u200b\u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430.' # noqa: E501
11 publisher = 'Habr Blockchain Publishing LTD'
12 category = 'blog'
13 cover_url = 'https://habr.com/img/habr_ru.png'
14 language = 'ru'
15 no_stylesheets = True
16 remove_javascript = False
17 auto_cleanup = False
18 oldest_article = 7
19 max_articles_per_feed = 50
20
21 remove_tags_before = dict(name='h1')
22
23 remove_tags_after = dict(name='div', attrs={'class': 'tm-misprint-area'})
24
25 remove_tags = [dict(name='div', attrs={'class': 'tm-article-presenter__meta'}), dict(name='div', attrs={'class': 'tm-article-poll'})]
26
27 feeds = [
28 ('\u041d\u043e\u0432\u043e\u0441\u0442\u0438', 'https://habr.com/ru/rss/news/?fl=ru'),
29 ('\u0412\u0441\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b', 'https://habr.com/ru/rss/all/all/?fl=ru'),
30 ('\u0420\u0435\u0439\u0442\u0438\u043d\u0433 \u226510', 'https://habr.com/ru/rss/all/top10/?fl=ru'),
31 ('\u0420\u0435\u0439\u0442\u0438\u043d\u0433 \u226525', 'https://habr.com/ru/rss/all/top25/?fl=ru'),
32 ('\u0420\u0435\u0439\u0442\u0438\u043d\u0433 \u226550', 'https://habr.com/ru/rss/all/top50/?fl=ru'),
33 ('\u0420\u0435\u0439\u0442\u0438\u043d\u0433 \u2265100', 'https://habr.com/ru/rss/all/top100/?fl=ru'),
34 ]
35
36 def preprocess_html(self, soup):
37 for img in soup.findAll('img', attrs={'data-src': True}):
38 img['src'] = img['data-src']
39 return soup