UNPKG

rsshub

Version:
53 lines (52 loc) 1.64 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/fzu/news.ts const route = { path: "/:type", categories: ["university"], example: "/fzu/jxtz", parameters: { type: "分类见下表" }, features: { antiCrawler: true }, name: "教务处通知", maintainers: ["Kare-Udon"], handler, description: `| 教学通知 | 专家讲座 | | -------- | -------- | | jxtz | zjjz |` }; const descriptionMap = { jxtz: "教学通知", zjjz: "嘉锡讲坛/信息素养讲座通知" }; const urlHead = "https://jwch.fzu.edu.cn/"; async function handler(ctx) { const { type } = ctx.req.param(); const $ = load(await rofetch(`${urlHead}${type}.htm`)); const list = $("ul.list-gl li").toArray().map((item) => { const $item = $(item); return { title: $item.find("a").attr("title"), link: urlHead + $item.find("a").attr("href"), pubDate: timezone(parseDate($item.find("span").text()), 8) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { if (item.link.includes("content.jsp")) return item; const $ = load(await rofetch(item.link)); return { ...item, description: $(".articelMain").html() }; }))); return { title: `福州大学教务处${$("h4").text().trim()}`, link: `http://jwch.fzu.edu.cn/${type}`, description: `福州大学教务处${descriptionMap[type] ?? ""}`, item: items }; } //#endregion export { route };