mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 01:58:11 +08:00
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const rootUrl = 'https://news.neea.cn';
|
|
const currentUrl = `${rootUrl}/JLPT/1/newslist.htm`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
|
|
let items = $('a')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
|
|
const matches = item.text().match(/(\d{4}-\d{2}-\d{2})/);
|
|
|
|
return {
|
|
title: item.text(),
|
|
link: `${rootUrl}/JLPT/1/${item.attr('href')}`,
|
|
pubDate: matches ? parseDate(matches[1]) : '',
|
|
};
|
|
});
|
|
|
|
items = await Promise.all(
|
|
items.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const detailResponse = await got({
|
|
method: 'get',
|
|
url: item.link,
|
|
});
|
|
|
|
const content = cheerio.load(detailResponse.data);
|
|
|
|
item.description = content('.dvContent').html();
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: '重要通知 - 教育部考试中心日本语能力测试',
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|