| 1 |
#!/usr/bin/env python |
| 2 |
# vim:fileencoding=utf-8 |
| 3 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 4 |
|
| 5 |
# feed source: https://www.nhk.or.jp/toppage/rss/index.html |
| 6 |
|
| 7 |
|
| 8 |
class ReutersJa(BasicNewsRecipe): |
| 9 |
title = 'NHK News' |
| 10 |
description = 'NHK News in Japanese' |
| 11 |
__author__ = 'Richard A. Steps' |
| 12 |
use_embedded_content = False |
| 13 |
language = 'ja' |
| 14 |
max_articles_per_feed = 30 |
| 15 |
remove_javascript = True |
| 16 |
auto_cleanup = True |
| 17 |
|
| 18 |
# This line added to deal with bots on site |
| 19 |
def get_browser(self, *a, **kw): |
| 20 |
kw['user_agent'] = 'common_words/based' |
| 21 |
return super().get_browser(*a, **kw) |
| 22 |
|
| 23 |
feeds = [ |
| 24 |
('主要ニュース', 'https://www.nhk.or.jp/rss/news/cat0.xml?format=xml'), |
| 25 |
('社会', 'https://www.nhk.or.jp/rss/news/cat1.xml?format=xml'), |
| 26 |
('科学・医療', 'https://www.nhk.or.jp/rss/news/cat3.xml?format=xml'), |
| 27 |
('政治', 'https://www.nhk.or.jp/rss/news/cat4.xml?format=xml'), |
| 28 |
('経済', 'https://www.nhk.or.jp/rss/news/cat5.xml?format=xml'), |
| 29 |
('国際', 'https://www.nhk.or.jp/rss/news/cat6.xml?format=xml'), |
| 30 |
('スポーツ', 'https://www.nhk.or.jp/rss/news/cat7.xml?format=xml'), |
| 31 |
('文化・エンタメ', 'https://www.nhk.or.jp/rss/news/cat2.xml?format=xml'), |
| 32 |
] |
| 33 |
|
| 34 |
def preprocess_html(self, soup): |
| 35 |
for img in soup.findAll('img', attrs={'data-src': True}): |
| 36 |
img['src'] = img['data-src'] |
| 37 |
return soup |