mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
* feat: add nippon.com * fix: nippon route * fix: nippon.com route * refactor: nippon route v2 * fix: nippon * Update lib/v2/nippon/index.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const category = ctx.params.category ?? 'Politics';
|
|
const path = category === 'Science,Technology' ? 'condition4' : 'category_code';
|
|
const res = await got.get(`https://www.nippon.com/api/search/cn/${path}/20/1/${category}?t=${Date.now()}`);
|
|
|
|
const list = res.data.body.dataList.map((item) => ({
|
|
title: item.title,
|
|
link: `https://www.nippon.com/${item.pub_url}`,
|
|
pubDate: item.pub_date,
|
|
}));
|
|
|
|
const item = await Promise.all(
|
|
list.slice(0, 10).map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const res = await got.get(item.link);
|
|
const $ = cheerio.load(res.data);
|
|
item.description = $('.editArea').html();
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: `走进日本 - ${category}`,
|
|
link: 'https://www.nippon.com/cn/economy/',
|
|
item,
|
|
};
|
|
};
|