rsshub
Version:
Make RSS Great Again!
54 lines (53 loc) • 1.57 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/xmu/aero.ts
const host = "https://aerospace.xmu.edu.cn";
const urlMap = {
tzgg: "/sy/xydt/tzgg/zjgx.htm",
bksjw: "/sy/rcpy/bkspy/tzgg.htm",
yjsjw: "/sy/rcpy/yjspy/tzgg.htm"
};
const titleMap = {
tzgg: "通知公告",
bksjw: "本科生教务",
yjsjw: "研究生教务"
};
const route = {
path: "/aero/:type",
categories: ["university"],
example: "/xmu/aero/yjsjw",
parameters: { type: "分类见下表" },
name: "航空航天学院",
maintainers: ["jch12138"],
handler,
description: `| 通知公告 | 本科生教务 | 研究生教务 |
| :------: | :--------: | :--------: |
| tzgg | bksjw | yjsjw |`
};
async function handler(ctx) {
const { type } = ctx.req.param();
const link = host + urlMap[type];
const $ = load(await rofetch(link));
const list = $(".ej_list ul li").toArray().map((item) => {
const $item = $(item);
const $a = $item.find("a");
return {
title: $a.attr("title") ?? "",
link: new URL($a.attr("href"), link).href,
pubDate: parseDate($item.find(".sj").text(), "YYYY-MM-DD")
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))(".v_news_content").html();
return item;
})));
return {
title: titleMap[type],
link,
item: items
};
}
//#endregion
export { route };