From 157bcb4cb6368edb572672b287676a78c28db34f Mon Sep 17 00:00:00 2001 From: Hiller Liao Date: Sun, 2 Jul 2023 23:11:03 +0800 Subject: [PATCH] nhk news easy --- rsshub/blueprints/main.py | 6 ++++++ rsshub/spiders/nhk/newseasy.py | 29 +++++++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 12 ++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 rsshub/spiders/nhk/newseasy.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index df1e3b0..b407b3b 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -296,6 +296,12 @@ def sysu_ifcen(category='', keywords=''): from rsshub.spiders.sysu.ifcen import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/nhk/newseasy') +@cache.cached(timeout=3600) +def nhk_newseasy(category='', keywords=''): + from rsshub.spiders.nhk.newseasy import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) + @bp.route('/filter/') def rss_filter(): from rsshub.spiders.rssfilter.filter import ctx diff --git a/rsshub/spiders/nhk/newseasy.py b/rsshub/spiders/nhk/newseasy.py new file mode 100644 index 0000000..7d95a2d --- /dev/null +++ b/rsshub/spiders/nhk/newseasy.py @@ -0,0 +1,29 @@ +import json +import requests +from rsshub.utils import DEFAULT_HEADERS + +domain = 'https://www3.nhk.or.jp' + + +def parse(post): + item = {} + item['title'] = post['title'] + item['description'] = post['title_with_ruby'] + '

' + post['outline_with_ruby'] + item['link'] = f"{domain}/news/easy/{post['news_id']}/{post['news_id']}.html" + return item + + +def ctx(category=''): + url = f'{domain}/news/easy/top-list.json' + posts = requests.get( + url, + headers=DEFAULT_HEADERS, + ).text + posts = json.loads(posts) + return { + 'title': 'News Web Easy - NHK', + 'link': f'{domain}/news/easy/', + 'description': 'NEWS WEB EASYは、小学生・中学生の皆さんや、日本に住んでいる外国人のみなさんに、わかりやすいことば でニュースを伝えるウェブサイトです。', + 'author': 'hillerliao', + 'items': list(map(parse, posts)), + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index b91145f..e46f6fb 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -42,6 +42,18 @@
+ +
+
+

NHK

+
NHK - Web News Easy by hillerliao
+

举例:https://pyrsshub.vercel.app/nhk/newseasy

+

路由:/nhk/newseasy

+
+
+
+ +