UNPKG

rsshub

Version:
50 lines (48 loc) 1.51 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 { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/xmut/jwc/yjs.ts const xmut = "https://yjs.xmut.edu.cn"; const route = { path: "/jwc/yjjw/:category?", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const { category = "yjsc" } = ctx.req.param(); const url = `${xmut}/index/${category}.htm`; const $ = load((await got_default(url, { headers: { referer: xmut }, https: { rejectUnauthorized: false } })).data); const items = $(".mainWrap .main_con .main_conR ul li").toArray().map((item) => { item = $(item); return { title: item.find("em").text(), link: `${xmut}/` + item.find("a").attr("href"), pubDate: parseDate(item.find("span").text()) }; }); const itemPromises = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { item.description = load((await got_default(item.link, { headers: { referer: xmut }, https: { rejectUnauthorized: false } })).data)("body .mainWrap .main_content .v_news_content").html(); return item; }))); return { title: $("title").text(), link: url, item: itemPromises }; } //#endregion export { route };