UNPKG

rsshub

Version:
61 lines (60 loc) 1.63 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/sctu/jwc/index.ts const route = { path: "/jwc/:category?", categories: ["university"], example: "/sctu/jwc/tzgg", parameters: { category: { description: "分类", options: [{ value: "tzgg", label: "通知公告" }, { value: "xwdt", label: "新闻动态" }], default: "tzgg" } }, radar: [{ source: ["www.sctu.edu.cn/jwc/wenzhangg/:category.htm"], target: "/jwc/:category" }], name: "教务处", maintainers: ["talenHuang"], handler, url: "www.sctu.edu.cn/jwc/" }; async function handler(ctx) { const { category = "tzgg" } = ctx.req.param(); const link = `https://www.sctu.edu.cn/jwc/wenzhangg/${category}.htm`; const response = await rofetch(link); const $ = load(response); const list = $(".main_conRCb ul li").toArray().map((item) => { const $item = $(item); const a = $item.find("a"); return { title: a.text(), link: new URL(a.attr("href"), link).href, pubDate: timezone(parseDate($item.find("span").text(), "YYYY-MM-DD"), 8) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const response = await rofetch(item.link); const $ = load(response); return { ...item, description: $(".v_news_content").html() }; }))); return { title: $("head title").text(), link, item: items }; } //#endregion export { route };