UNPKG

rsshub

Version:
44 lines (43 loc) 1.31 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/cpu/home.ts const route = { path: "/home", categories: ["university"], example: "/cpu/home", name: "最新公告", maintainers: ["kba977"], handler }; async function handler() { const baseUrl = "https://www.cpu.edu.cn"; const url = `${baseUrl}/4133/list.htm`; const response = await rofetch(url); const $ = load(response); const list = $(".col_news_list li.news").toArray().map((item) => { const $item = $(item); const a = $item.find(".news_title a"); return { title: a.attr("title") || a.text(), link: new URL(a.attr("href"), baseUrl).href, pubDate: parseDate($item.find(".news_meta").text()) }; }); return { title: "中国药科大学 | 最新公告", link: url, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { try { const detail = await rofetch(item.link); const $ = load(detail); item.description = $(".wp_articlecontent").html() ?? $(".v_news_content").html(); } catch {} return item; }))), description: "中国药科大学 | 最新公告" }; } //#endregion export { route };