rsshub
Version:
Make RSS Great Again!
47 lines (45 loc) • 1.47 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/xjtu/dyyy/index.ts
const baseUrl = "http://www.dyyy.xjtu.edu.cn";
const route = {
path: "/dyyy/:path{.+}",
name: "Unknown",
maintainers: [],
handler
};
async function handler(ctx) {
const path = ctx.req.param("path");
const response = await got_default(`${baseUrl}/${path}.htm`);
const $ = load(response.data);
const items = $(".list_right_con div li").toArray().map((item) => {
item = $(item);
return {
title: item.find("a").attr("title"),
link: new URL(item.find("a").attr("href"), response.url).href,
pubDate: parseDate(item.find(".data").text())
};
});
await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const { data: response$1 } = await got_default(item.link);
const $$1 = load(response$1);
item.author = $$1(".content_source").text().match(/责任编辑:(.*)\(点击/)[1];
item.description = $$1(".content_con").html();
return item;
})));
return {
title: $("head title").text(),
link: `${baseUrl}/${path}.htm`,
item: items
};
}
//#endregion
export { route };