rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 1.77 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import { t as ofetch_default } from "./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 { load } from "cheerio";
//#region lib/routes/cqu/index.ts
const route = {
path: "/jwc/:path{.+}?",
categories: ["university"],
example: "/cqu/jwc/index/tzgg",
parameters: { path: {
description: "路径参数,默认为 `index/tzgg`",
default: "index/tzgg"
} },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["jwc.cqu.edu.cn/:path"],
target: "/jwc/:path"
}],
name: "本科教学信息网通知",
maintainers: ["AhsokaTano26"],
handler
};
async function handler(ctx) {
const { path = "index/tzgg" } = ctx.req.param();
const url = new URL(`${path}.htm`, "http://jwc.cqu.edu.cn").href;
const $ = load(await ofetch_default(url));
const list = $("div.page-contner.fl li.pot-r").toArray().map((item) => {
item = $(item);
const a = item.find("a.no-wrap");
const link = new URL(a.attr("href"), url).href;
return {
title: a.attr("title"),
link,
pubDate: parseDate(item.find("span.fr").text())
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await ofetch_default(item.link))("form[name=\"_newscontent_fromname\"] div#vsb_content").find("div.v_news_content").html();
return item;
})));
return {
title: $("title").text().replace(/--/, " - "),
link: url,
item: items
};
}
//#endregion
export { route };