UNPKG

rsshub

Version:
41 lines (40 loc) 1.43 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/cug/undergraduate.ts const route = { path: "/undergraduate", categories: ["university"], example: "/cug/undergraduate", name: "中国地质大学通知公告", maintainers: ["chunibyo-wly"], handler }; async function handler() { const baseUrl = "https://www.cug.edu.cn/index/tzgg.htm"; const $ = load(await rofetch(baseUrl)); const list = $(".xb-list li.xblist-oli"); return { title: "中国地质大学(武汉) - 综合通知公告", link: baseUrl, item: await Promise.all(list.toArray().map((element) => { const $element = $(element); const link = new URL($element.find(".xblist-title a").attr("href"), baseUrl).href; const item = { title: $element.find(".xblist-title h2").text(), link, pubDate: timezone(parseDate(`${$element.find(".xblist-date p").text()}-${$element.find(".xblist-date h2").text()}`, "YYYY-MM-DD"), 8) }; if (!new URL(link).hostname.endsWith("www.cug.edu.cn")) return item; return cache_default.tryGet(link, async () => { const $ = load(await rofetch(link)); item.description = $(".v_news_content").html(); return item; }); })) }; } //#endregion export { route };