rsshub
Version:
Make RSS Great Again!
53 lines (52 loc) • 1.41 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/nchu/jwc.ts
const host = "https://jwc.nchu.edu.cn";
const map = {
notice: "gg",
news: "xw"
};
const route = {
path: "/jwc/:type?",
categories: ["university"],
example: "/nchu/jwc/notice",
parameters: { type: "默认为 `notice`" },
radar: [{
source: ["jwc.nchu.edu.cn/xwzx/gg"],
target: "/jwc/notice"
}, {
source: ["jwc.nchu.edu.cn/xwzx/xw"],
target: "/jwc/news"
}],
name: "教务处公告与新闻",
maintainers: ["Sg4Dylan"],
description: `| 教务公告 | 教务新闻 |
| -------- | -------- |
| notice | news |`,
handler
};
async function handler(ctx) {
const { type = "notice" } = ctx.req.param();
const link = `${host}/xwzx/${map[type]}`;
const $ = load(await rofetch(link));
const items = $(".pageTPList li").toArray().map((item) => {
const $item = $(item);
const a = $item.find(".title a");
return {
title: a.text(),
link: new URL(a.attr("href"), host).href,
description: $item.find(".intro").text().trim(),
pubDate: timezone(parseDate($item.find(".date").text().replace("发表时间:", "")), 8)
};
});
return {
title: $("head title").text(),
link,
language: "zh-CN",
item: items
};
}
//#endregion
export { route };