rsshub
Version:
Make RSS Great Again!
55 lines (54 loc) • 1.63 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 { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/kmust/jwc.ts
const route = {
path: "/jwc/:type?",
categories: ["university"],
example: "/kmust/jwc/notify",
parameters: { type: "默认为 `notify`" },
name: "教务处",
maintainers: ["geekrainy"],
description: `| 教务通知 | 教务新闻 |
| -------- | -------- |
| notify | news |`,
handler
};
const baseUrl = "https://jwc.kmust.edu.cn";
const typeProps = {
notify: {
url: "/jwtz/jwtz.htm",
title: "教务通知"
},
news: {
url: "/jwxw/jwxw.htm",
title: "教务新闻"
}
};
async function handler(ctx) {
const { type = "notify" } = ctx.req.param();
const pageUrl = new URL(typeProps[type].url, baseUrl).href;
const title = `${typeProps[type].title}-昆明理工大学`;
const $ = load(await rofetch(pageUrl));
const list = $("table.normalfont tr a[target=\"_blank\"]").toArray().map((item) => {
const $item = $(item);
return {
link: new URL($item.attr("href"), pageUrl).href,
title: $item.text().trim()
};
});
return {
link: pageUrl,
title,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load(await rofetch(item.link));
item.pubDate = timezone(parseDate($(".gray").text().replace("发布时间:", ""), "YYYY-MM-DD"), 8);
item.description = $(".v_news_content").html();
return item;
})))
};
}
//#endregion
export { route };