UNPKG

rsshub

Version:
45 lines (43 loc) 1.37 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 { t as got_default } from "./got-CO-ndVl2.mjs"; import { load } from "cheerio"; //#region lib/routes/cas/is/index.ts const baseUrl = "https://is.cas.cn"; const route = { path: "/is/:path{.+}", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const path = ctx.req.param("path"); const response = await got_default(`${baseUrl}/${path}/`); const $ = load(response.data); const items = $(".list-news ul li").toArray().map((item) => { item = $(item); return { title: item.find("a").text(), link: new URL(item.find("a").attr("href"), response.url).href, pubDate: parseDate(item.find("span").text().replaceAll("[]", "")) }; }); await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { if (!item.link.startsWith(`${baseUrl}/`)) return item; item.description = load((await got_default(item.link)).data)(".TRS_Editor").html(); return item; }))); return { title: $("head title").text(), link: `${baseUrl}/${path}`, item: items }; } //#endregion export { route };