UNPKG

rsshub

Version:
54 lines (52 loc) 1.74 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { r as getSubPath } from "./common-utils-vrWQFAEk.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/nuist/yjs.ts const route = { path: "/yjs/*", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const currentUrl = `https://yjs.nuist.edu.cn/${getSubPath(ctx) === "/yjs/" ? "index/tzgg" : getSubPath(ctx).replace(/^\/yjs\//, "")}.htm`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".gridlinediv").toArray().map((item) => { item = $(item); const a = item.find("a").last(); return { title: a.text(), link: new URL(a.attr("href"), currentUrl).href, pubDate: parseDate(item.next().text(), "YYYY年MM月DD日") }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); const timeMatches = content(".bar").text().match(/(\d{4}年\d{2}月\d{2}日 \d{2}:\d{2})/); item.description = content(".v_news_content").html(); item.pubDate = timeMatches ? timezone(parseDate(timeMatches[1], "YYYY年MM月DD日 HH:mm"), 8) : item.pubDate; return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };