UNPKG

rsshub

Version:
54 lines (52 loc) 1.74 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { r as getSubPath } from "./common-utils-Cz5bFBus.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.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 };