mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
NHK News Web Easy Support (#824)
* 🐛 修复了知乎热榜时间错误的bug * ✨ 知乎热榜添加作者信息 * 🐛 使用更加合理的 guid * ✨ NHK News Web Easy Support
This commit is contained in:
@@ -1270,6 +1270,10 @@ Category 列表:
|
||||
|
||||
</route>
|
||||
|
||||
### NHK
|
||||
|
||||
<route name="News Web Easy" author="Andiedie" example="/nhk/news_web_easy" path="/nhk/news_web_easy"/>
|
||||
|
||||
### BBC
|
||||
|
||||
<route name="BBC" author="HenryQW" example="/bbc/chinese" path="/bbc/:channel?" :paramsDesc="['分类, 缺省为环球新闻']">
|
||||
|
||||
@@ -598,6 +598,9 @@ router.get('/dytt/index', require('./routes/dytt/index'));
|
||||
// 趣头条
|
||||
router.get('/qutoutiao/category/:cid', require('./routes/qutoutiao/category'));
|
||||
|
||||
// NHK NEW WEB EASY
|
||||
router.get('/nhk/news_web_easy', require('./routes/nhk/news_web_easy'));
|
||||
|
||||
// BBC
|
||||
router.get('/bbc/:channel?', require('./routes/bbc/index'));
|
||||
|
||||
|
||||
40
routes/nhk/news_web_easy.js
Normal file
40
routes/nhk/news_web_easy.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data } = await axios.get('https://www3.nhk.or.jp/news/easy/news-list.json');
|
||||
const dates = JSON.parse(data.trim())[0];
|
||||
|
||||
let items = [];
|
||||
for (const articles of Object.values(dates)) {
|
||||
for (const article of articles) {
|
||||
items.push({
|
||||
title: article.title,
|
||||
description: `<h1>${article.title_with_ruby}</h1><img referrerpolicy="no-referrer" src="${article.news_web_image_uri}"/><br/>`,
|
||||
guid: article.news_id,
|
||||
pubDate: new Date(article.news_publication_time).toUTCString(),
|
||||
link: `https://www3.nhk.or.jp/news/easy/${article.news_id}/${article.news_id}.html`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
items = items.sort((a, b) => b.pubDate - a.pubDate).slice(0, 10);
|
||||
|
||||
const promises = [];
|
||||
const getDetail = async (item) => {
|
||||
const { data } = await axios.get(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
item.description += $('.article-body').html();
|
||||
};
|
||||
for (const item of items) {
|
||||
promises.push(getDetail(item));
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'NEWS WEB EASY',
|
||||
link: 'https://www3.nhk.or.jp/news/easy/',
|
||||
description: 'NEWS WEB EASYは、小学生・中学生の皆さんや、日本に住んでいる外国人のみなさんに、わかりやすいことば でニュースを伝えるウェブサイトです。',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user