rsshub
Version:
Make RSS Great Again!
45 lines (43 loc) • 1.37 kB
JavaScript
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/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 };