mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
* feat(route): add 东北大学医学与生物信息工程学院 * Update lib/routes/universities/neu/bmie.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/universities/neu/bmie.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(route): 更新BMIE 格式化日期、采用V2路由 * Apply suggestions from code review Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(route):采用 pubDate 解析 * refactor: migrate to v2 Co-authored-by: Athena <qingcaomc+zen@gmail.com>
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const baseUrl = 'https://neunews.neu.edu.cn';
|
|
|
|
module.exports = async (ctx) => {
|
|
const type = ctx.params.type;
|
|
const newsUrl = `${baseUrl}/${type}/list.htm`;
|
|
const response = await got(newsUrl);
|
|
|
|
const data = response.data;
|
|
const $ = cheerio.load(data);
|
|
|
|
const items = $('.column-news-list > .news_list > .news')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
return {
|
|
title: item.find('a').attr('title'),
|
|
link: new URL(item.find('a').attr('href'), baseUrl).href,
|
|
pubDate: parseDate(item.find('.news_meta').text(), 'YYYY-MM-DD'),
|
|
};
|
|
});
|
|
|
|
const results = await Promise.all(
|
|
items.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const result = await got(item.link);
|
|
const $ = cheerio.load(result.data);
|
|
|
|
item.author = $('.arti-metas').text().split('更新日期')[0];
|
|
item.description = $('.article_content').html();
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: `东北大学新闻网-${$('head title').text()}`,
|
|
link: newsUrl,
|
|
item: results,
|
|
};
|
|
};
|