diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index cdcc2f8..173d84e 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -310,6 +310,12 @@ def nhk_newseasy(category='', keywords=''): from rsshub.spiders.nhk.newseasy import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/nhk/topic/') +@cache.cached(timeout=3600) +def nhk_topic(category='', keywords=''): + from rsshub.spiders.nhk.topic import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) + @bp.route('/tadoku/books/') @cache.cached(timeout=3600) def tadoku_books(category=''): diff --git a/rsshub/spiders/nhk/topic.py b/rsshub/spiders/nhk/topic.py new file mode 100644 index 0000000..da481a0 --- /dev/null +++ b/rsshub/spiders/nhk/topic.py @@ -0,0 +1,35 @@ +import json +import requests +import arrow +from rsshub.utils import DEFAULT_HEADERS + +domain = 'https://www3.nhk.or.jp' + + +def date_format(pubDate): + date = arrow.get(pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') + iso = date.isoformat() + return iso + +def parse(post): + item = {} + item['title'] = post['title'] + item['description'] = post['title'] + item['link'] = domain + post['link'] + item['pubDate'] = date_format(post['pubDate']) + item['author'] = 'NHK' + return item + + +def ctx(category=''): + url = f'{domain}/news/json16/word/{category}_001.json?_=1705840617679' + posts = requests.get(url) + word = json.loads(posts.text)['channel']['word'] + posts = json.loads(posts.text)['channel']['item'] + return { + 'title': f'{word} - NHK News', + 'link': f'{domain}/news/word/{category}.html', + 'description': f'{word}の最新ニュース・特集一覧', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } \ No newline at end of file diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 6980caf..f37e2b0 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -49,6 +49,12 @@
NHK - Web News Easy by hillerliao

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

路由:/nhk/newseasy

+ +
NHK - topic news by hillerliao
+

举例:https://pyrsshub.vercel.app/nhk/topic/0001595

+

路由:/nhk/topic/:category

+

参数:category, topic id

+