rsshub
Version:
Make RSS Great Again!
75 lines (73 loc) • 2.21 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 "./helpers-DxBp0Pty.mjs";
import "./proxy-Db7uGcYb.mjs";
import "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs";
import "./puppeteer-DGmvuGvT.mjs";
import { t as getContent } from "./utils-BFQW6UlK.mjs";
import { load } from "cheerio";
//#region lib/routes/njust/jwc.ts
const map = new Map([
["jstz", {
title: "南京理工大学教务处 -- 教师通知",
id: "/1216"
}],
["xstz", {
title: "南京理工大学教务处 -- 学生通知",
id: "/1217"
}],
["xw", {
title: "南京理工大学教务处 -- 新闻",
id: "/1218"
}],
["xydt", {
title: "南京理工大学教务处 -- 学院动态",
id: "/1219"
}]
]);
const host = "https://jwc.njust.edu.cn";
const route = {
path: "/jwc/:type?",
categories: ["university"],
example: "/njust/jwc/xstz",
parameters: { type: "分类名,见下表,默认为学生通知" },
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "教务处",
maintainers: ["MilkShakeYoung", "jasongzy"],
handler,
description: `| 教师通知 | 学生通知 | 新闻 | 学院动态 |
| -------- | -------- | ---- | -------- |
| jstz | xstz | xw | xydt |`
};
async function handler(ctx) {
const type = ctx.req.param("type") ?? "xstz";
const info = map.get(type);
if (!info) throw new invalid_parameter_default("invalid type");
const siteUrl = host + info.id + "/list.htm";
const $ = load(await getContent(siteUrl, true));
const list = $("div#wp_news_w3").find("tr");
return {
title: info.title,
link: siteUrl,
item: list.toArray().map((item) => ({
title: $(item).find("a").attr("title").trim(),
pubDate: timezone(parseDate($(item).find("td[width=\"14%\"]").text(), "YYYY-MM-DD"), 8),
link: $(item).find("a").attr("href")
}))
};
}
//#endregion
export { route };