rsshub
Version:
Make RSS Great Again!
56 lines (54 loc) • 1.74 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 { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/jseea/news.ts
const baseUrl = "https://www.jseea.cn";
const siteTitle = " - 江苏省教育考试院";
async function loadContent(link) {
const { data: response } = await got_default(link);
const $ = load(response);
$("strong").remove();
return $("#content").html();
}
const route = {
path: "/news/:type?",
radar: [{
source: ["jseea.cn/webfile/news/:type"],
target: "/news/:type"
}],
name: "Unknown",
maintainers: ["schen1024"],
handler
};
async function handler(ctx) {
const listPageUrl = `${baseUrl}/webfile/news/${ctx.req.param("type") ?? "zkyw"}/`;
const { data: response } = await got_default(listPageUrl);
const $ = load(response);
const list = $("div.content-list-div ul li a").toArray().map((item) => {
item = $(item);
return {
title: item.contents().filter((_, e) => e.nodeType === 3).text().trim(),
link: `https:${item.attr("href")}`,
pubDate: timezone(parseDate(item.find("span").text(), "YYYY-MM-DD"), 8)
};
});
const result = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = await loadContent(item.link);
return item;
})));
return {
title: $("head title").text() + siteTitle,
link: listPageUrl,
item: result
};
}
//#endregion
export { route };