UNPKG

rsshub

Version:
44 lines (43 loc) 1.6 kB
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/jlbtc/jwc.ts const route = { path: "/jwc/:category{.+}?", categories: ["university"], example: "/jlbtc/jwc", parameters: { category: "分类,见下表,默认为通知公告" }, name: "教务处", maintainers: ["nczitzk"], description: `| 教务新闻 | 通知公告 | 教务管理 | 教师发展 | 学籍考务工作 | 教学建设 | | ---------- | ---------- | --------- | -------- | ------------ | -------- | | index/tpxw | index/tzgg | szdw/jwgl | jjj | xjkwgz | zyjs |`, handler }; async function handler(ctx) { const { category = "index/tzgg" } = ctx.req.param(); const currentUrl = `https://jwc1.jlbtc.edu.cn/${category}.htm`; const $ = load(await rofetch(currentUrl)); const list = $("li a[target=\"_blank\"]").toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: new URL($item.attr("href"), currentUrl).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); item.description = content(".v_news_content").html(); item.pubDate = timezone(parseDate(content(".timestyle2172").text()), 8); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };