UNPKG

rsshub

Version:
46 lines (45 loc) 1.5 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/hzcu/news.ts const route = { path: "/news/latest", categories: ["university"], example: "/hzcu/news/latest", radar: [{ source: ["www.hzcu.edu.cn/xw/xxyw.htm"] }], name: "学校要闻", maintainers: ["zhang-wangz"], handler, url: "www.hzcu.edu.cn/xw/xxyw.htm" }; const baseUrl = "https://www.hzcu.edu.cn"; async function handler(ctx) { const link = `${baseUrl}/xw/xxyw.htm`; const $ = load(await rofetch(link)); const list = $("ul.ul-imgtxtq6 li a.con").toArray().map((item) => { const $item = $(item); const day = $item.find(".pic em").text(); const yearMonth = $item.find(".pic span").contents().last().text(); return { title: $item.find(".txt h3").text(), link: new URL($item.attr("href"), link).href, pubDate: timezone(parseDate(`${yearMonth}.${day}`, "YYYY.MM.DD"), 8) }; }).slice(0, ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 10); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load(await rofetch(item.link)); return { ...item, description: $("#vsb_content .v_news_content").html() }; }))); return { title: $("head title").text(), link, item: items }; } //#endregion export { route };