mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
* update zju/grs in university * refactor: migrate to v2 * fix: add radar * fix: not working routes * fix: add migration note * docs: remove N/A types from physics table * fix(radar): migrate old rules
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
async function getPage(id) {
|
|
const res = await got({
|
|
method: 'get',
|
|
url: `http://www.cst.zju.edu.cn/${id}/list.htm`,
|
|
});
|
|
const $ = cheerio.load(res.data);
|
|
const content = $('.lm_new ul li');
|
|
|
|
return (
|
|
content &&
|
|
content
|
|
.map((index, item) => {
|
|
item = $(item);
|
|
|
|
const title = item.find('a').text();
|
|
const pubDate = parseDate(item.find('.fr').text());
|
|
const link = item.find('a').attr('href');
|
|
|
|
return {
|
|
title,
|
|
pubDate,
|
|
link,
|
|
};
|
|
})
|
|
.get()
|
|
);
|
|
}
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id.split('+');
|
|
const tasks = id.map((id) => getPage(id));
|
|
const results = await Promise.all(tasks);
|
|
let items = [];
|
|
results.forEach((result) => (items = items.concat(result)));
|
|
|
|
ctx.state.data = {
|
|
title: '浙江大学软件学院通知',
|
|
link: 'http://www.cst.zju.edu.cn/',
|
|
item: items,
|
|
};
|
|
};
|