UNPKG

rsshub

Version:
41 lines (40 loc) 1.24 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/henu/news.ts const baseUrl = "https://jwc.henu.edu.cn"; const map = { tzgg: "/tzgg.htm", jxdt: "/jxdt.htm", mtbd: "/jxdt/mtbd.htm" }; const route = { path: "/:type?", categories: ["university"], example: "/henu/tzgg", parameters: { type: "分类,见下表,默认为通知公告" }, name: "教务处", maintainers: ["CasterWx"], description: `| 通知公告 | 教学动态 | 媒体报道 | | -------- | -------- | -------- | | tzgg | jxdt | mtbd |`, handler }; async function handler(ctx) { const { type = "tzgg" } = ctx.req.param(); const link = `${baseUrl}${map[type]}`; const response = await rofetch(link, { headers: { Referer: link } }); const $ = load(response); return { link, title: $("title").text(), item: $(".article-list li").toArray().map((elem) => ({ link: new URL($("a", elem).attr("href"), link).href, title: $(".article-title", elem).text(), pubDate: timezone(parseDate($(".article-date", elem).text()), 8) })) }; } //#endregion export { route };