UNPKG

rsshub

Version:
52 lines (51 loc) 1.66 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/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 response = await rofetch(link); const $ = load(response); 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 detail = await rofetch(itemUrl); const $$ = load(detail); 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 };