Files
RSSHub/lib/v2/seu/yjs.js
T
PyangWU 32889f5f58 feat(route): add 东南大学研究生院公告 (#12958)
* feat(route): add 东南大学研究生院公告

* feat(route): add 东南大学研究生院公告

* add radar

* format scripts

* Update lib/v2/seu/radar.js

* Update lib/v2/seu/yjs.js

* Update lib/v2/seu/yjs.js

* fix redundancy

* refactor: migrate to v2

* fix: typo

---------
2023-08-11 20:59:13 +08:00

38 lines
1.2 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = 'https://seugs.seu.edu.cn/26671/list.htm';
module.exports = async (ctx) => {
const response = await got(url);
const $ = cheerio.load(response.data);
const list = $('.news')
.toArray()
.map((element) => {
const info = {
title: $(element).find('span.news_title > a').attr('title'),
link: `https://seugs.seu.edu.cn${$(element).find('span.news_title > a').attr('href')}`,
date: $(element).find('span.news_meta').text(),
};
return info;
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
item.description = $('.wp_articlecontent').html();
item.pubDate = new Date(item.date).toUTCString();
return item;
})
)
);
ctx.state.data = {
title: '东南大学研究生公告',
link: url,
item: items,
};
};