UNPKG

rsshub

Version:
47 lines (45 loc) 1.55 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/xjtu/international.ts const route = { path: "/international/:subpath{.+}", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const subpath = ctx.req.param("subpath"); const base = "http://international.xjtu.edu.cn"; const url = `${base}/${subpath.split(".")[0]}.htm`; const $ = load((await got_default(url)).data); const name = $("div.pageTitle").text(); const list = $(".news-list-a > .c").toArray().map((item$1) => { item$1 = $(item$1); return { title: item$1.find("a").attr("title"), pubDate: parseDate(item$1.find("p.list-time").text()), link: new URL(item$1.find("a").attr("href"), base).href }; }); const item = await Promise.all(list.map((item$1) => cache_default.tryGet(item$1.link, async () => { if (new URL(item$1.link).pathname.startsWith === "/content.jsp") return item$1; item$1.description = load((await got_default(item$1.link)).data)("div.ctnCont").html(); return item$1; }))); return { title: `西安交通大学国际处 - ${name}`, link: url, description: `西安交通大学国际处 - ${name}`, item }; } //#endregion export { route };