UNPKG

rsshub

Version:
50 lines (49 loc) 1.61 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/ahau/jwc.ts const route = { path: "/jwc/:type", categories: ["university"], example: "/ahau/jwc/jwyw", parameters: { type: "类型名" }, name: "教务处", maintainers: ["SimonHu-HN"], handler, description: `| 教务要闻 | 通知公告 | | -------- | -------- | | jwyw | tzgg |` }; async function handler(ctx) { const { type } = ctx.req.param(); const host = "https://jwc.ahau.edu.cn/xz/wzsy/"; const link = `${host}${type}.htm`; const $ = load(await rofetch(link)); const title = $("meta[name=\"pageTitle\"]").attr("content"); const list = $(".list li a.clearfix, .w-list li a").slice(0, 20).toArray(); const result = await Promise.all(list.map((item) => { const $item = $(item); const itemUrl = new URL($item.attr("href"), host).href; return cache_default.tryGet(itemUrl, async () => { const $$ = load(await rofetch(itemUrl)); return { title: $item.attr("title"), link: itemUrl, author: "安农大教务处", guid: itemUrl, description: $$("#vsb_content > .v_news_content").html(), pubDate: timezone(parseDate($$(".wzxx").text().match(/\d{4}-\d{2}-\d{2}/)[0]), 8) }; }); })); return { title: `安徽农业大学教务处 - ${title}`, link, description: `安徽农业大学教务处 - ${title}`, item: result }; } //#endregion export { route };