UNPKG

rsshub

Version:
59 lines (58 loc) 1.68 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 { load } from "cheerio"; //#region lib/routes/zzu/soft-news.ts const route = { path: "/soft/news/:type?", categories: ["university"], example: "/zzu/soft/news/xyxw", parameters: { type: "可选,默认为 `xyxw`" }, name: "计算机与人工智能学院(软件学院)", maintainers: ["nia3y"], handler, description: `| 参数名称 | 学院动态 | 通知公告 | | -------- | -------- | -------- | | 参数 | xyxw | tzgg |` }; const baseUrl = "https://www7.zzu.edu.cn/csai/"; const config = { xyxw: { title: "学院动态", url: `${baseUrl}xydt.htm` }, tzgg: { title: "通知公告", url: `${baseUrl}tzgg.htm` } }; async function handler(ctx) { const { type = "xyxw" } = ctx.req.param(); const { title, url } = config[type]; const response = await rofetch(url); const $ = load(response); const list = $(".list li").toArray().map((v) => { const $v = $(v); return { link: new URL($v.find("a").attr("href"), url).href, title: $v.find("a").text(), pubDate: parseDate($v.find("span").text()) }; }); const out = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await rofetch(item.link); const $ = load(detailResponse); return { ...item, author: "计算机与人工智能学院", description: $(".v_news_content").html() }; }))); return { title: `郑州大学计算机与人工智能学院 -- ${title}`, link: url, item: out }; } //#endregion export { route };