rsshub
Version:
Make RSS Great Again!
68 lines (66 loc) • 2.35 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { load } from "cheerio";
//#region lib/routes/ncku/csie.ts
const currentURL = (catagory, page) => catagory === "_all" ? `https://www.csie.ncku.edu.tw/zh-hant/news?page=${page}` : `https://www.csie.ncku.edu.tw/zh-hant/news/${catagory}?page=${page}`;
const catagories = {
_all: "全部資訊",
normal: "一般資訊",
bachelorAdmission: "大學部招生",
masterAdmission: "研究所招生",
speeches: "演講及活動資訊",
awards: "獲獎資訊",
scholarship: "獎助學金",
jobs: "徵人資訊"
};
const route = {
"zh-TW": {
name: "國立成功大學資訊系公告",
description: "可用分類:_all, normal, bachelorAdmission, masterAdmission, speeches, awards, scholarship, jobs"
},
name: "CSIE News",
description: "Availible catagories:_all, normal, bachelorAdmission, masterAdmission, speeches, awards, scholarship, jobs",
path: "/csie/:catagory?",
categories: ["university"],
example: "/ncku/csie/normal",
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["www.csie.ncku.edu.tw/zh-hant/news/"],
target: "/csie/_all"
}, {
source: ["www.csie.ncku.edu.tw/zh-hant/news/:catagory"],
target: "/csie/:catagory"
}],
maintainers: ["simbafs"],
handler: async (ctx) => {
let catagory = ctx.req.param("catagory") ?? "_all";
if (catagories[catagory] === void 0) catagory = "normal";
const base = 1;
const item = (await Promise.allSettled(Array.from({ length: 3 }).map(async (_, i) => {
const $ = await ofetch_default(currentURL(catagory, base + i), { parseResponse: load });
return $(".list-title > li").toArray().map((e) => ({
title: $("a", e).text(),
pubDate: new Date($("small", e).text()),
link: `https://www.csie.ncku.edu.tw${$("a", e).attr("href")}`,
catagory: $("span:nth-child(2)", e).text()
}));
}))).filter((item$1) => item$1.status === "fulfilled").flatMap((item$1) => item$1.value);
return {
title: `成大資訊系公告 - ${catagories[catagory]}`,
link: currentURL(catagory, base),
item
};
}
};
//#endregion
export { route };