rsshub
Version:
Make RSS Great Again!
106 lines (101 loc) • 3.25 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 "./puppeteer-DGmvuGvT.mjs";
import { t as getContent } from "./utils-BFQW6UlK.mjs";
import { load } from "cheerio";
//#region lib/routes/njust/eo.ts
const map = new Map([
["16tz", {
title: "南京理工大学电光16 -- 通知公告",
id: "/_t217/tzgg"
}],
["16dt", {
title: "南京理工大学电光16 -- 主任寄语",
id: "/_t217/zrjy"
}],
["17tz", {
title: "南京理工大学电光17 -- 年级通知",
id: "/_t689/njtz"
}],
["17dt", {
title: "南京理工大学电光17 -- 每日动态",
id: "/_t689/mrdt"
}],
["18tz", {
title: "南京理工大学电光18 -- 年级通知",
id: "/_t900/njtz_10234"
}],
["18dt", {
title: "南京理工大学电光18 -- 主任寄语",
id: "/_t900/zrjy_10251"
}],
["19tz", {
title: "南京理工大学电光19 -- 通知公告",
id: "/_t1163/tzgg_11606"
}],
["19dt", {
title: "南京理工大学电光19 -- 每日动态",
id: "/_t1163/mrdt_11608"
}]
]);
const host = "https://dgxg.njust.edu.cn";
const route = {
path: "/eo/:grade?/:type?",
categories: ["university"],
example: "/njust/eo/17/tz",
parameters: {
grade: "年级,见下表,默认为本科 2017 级,未列出的年级所对应的参数可以从级网二级页面的 URL Path 中找到,例如:本科 2020 级为 `_t1316`",
type: "类别,见下表,默认为年级通知(通知公告),未列出的类别所对应的参数可以从级网二级页面的 URL Path 中找到,例如:电光 20 的通知公告为 `tzgg_12969`"
},
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "电光学院年级网站",
maintainers: ["jasongzy"],
handler,
description: `\`grade\` 列表:
| 本科 2016 级 | 本科 2017 级 | 本科 2018 级 | 本科 2019 级 |
| ------------ | ------------ | ------------ | ------------ |
| 16 | 17 | 18 | 19 |
\`type\` 列表:
| 年级通知(通知公告) | 每日动态(主任寄语) |
| -------------------- | -------------------- |
| tz | dt |`
};
async function handler(ctx) {
const grade = ctx.req.param("grade") ?? "17";
const type = ctx.req.param("type") ?? "tz";
let info = map.get(grade + type);
if (!info) info = {
title: "",
id: "/" + grade + "/" + type
};
const siteUrl = host + info.id + "/list.htm";
const $ = load(await getContent(siteUrl, true));
if (!info.title) info.title = $("title").text();
const list = $("li.list_item");
return {
title: info.title,
link: siteUrl,
item: list.toArray().map((item) => ({
title: $(item).find("a").text().trim(),
pubDate: timezone(parseDate($(item).find("span.Article_PublishDate").text(), "YYYY-MM-DD"), 8),
link: $(item).find("a").attr("href")
}))
};
}
//#endregion
export { route };