UNPKG

rsshub

Version:
49 lines (48 loc) 1.65 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs"; import { load } from "cheerio"; //#region lib/routes/guat/news.ts const route = { path: "/news/:type?", categories: ["university"], example: "/guat/news/ghyw", parameters: { type: "资讯类型,如下表" }, name: "新闻资讯", maintainers: ["wyml"], description: `| 桂航要闻 | 最新动态 | 通知公告 | 信息公开 | | -------- | -------- | -------- | -------- | | ghyw | zxdt | tzgg | xxgk |`, handler }; const host = "https://www.guat.edu.cn"; const urls = { ghyw: `${host}/index/ghyw.htm`, zxdt: `${host}/index/zxdt.htm`, tzgg: `${host}/tzgg/tzgg.htm`, xxgk: `${host}/tzgg/xxgk.htm` }; async function handler(ctx) { const { type = "ghyw" } = ctx.req.param(); const url = urls[type]; if (!url) throw new InvalidParameterError("参数不在可选范围之内"); const $ = load(await rofetch(url)); const list = $(".list_pic li a, div.list ul li a").toArray().map((item) => { const $item = $(item); const sj = $item.find(".sj"); return { title: $item.attr("title"), link: new URL($item.attr("href"), url).href, description: $item.find(".zy").text(), pubDate: timezone(parseDate(sj.length ? `${sj.find("span").text()}-${sj.find("p").text()}` : $item.find("span").text()), 8) }; }); return { title: `桂林航天工业学院 - ${$(".ej_main h2").text().trim()}`, link: url, item: list }; } //#endregion export { route };