rsshub
Version:
Make RSS Great Again!
40 lines (39 loc) • 1.21 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/henu/news.ts
const baseUrl = "https://jwc.henu.edu.cn";
const map = {
tzgg: "/tzgg.htm",
jxdt: "/jxdt.htm",
mtbd: "/jxdt/mtbd.htm"
};
const route = {
path: "/:type?",
categories: ["university"],
example: "/henu/tzgg",
parameters: { type: "分类,见下表,默认为通知公告" },
name: "教务处",
maintainers: ["CasterWx"],
description: `| 通知公告 | 教学动态 | 媒体报道 |
| -------- | -------- | -------- |
| tzgg | jxdt | mtbd |`,
handler
};
async function handler(ctx) {
const { type = "tzgg" } = ctx.req.param();
const link = `${baseUrl}${map[type]}`;
const $ = load(await rofetch(link, { headers: { Referer: link } }));
return {
link,
title: $("title").text(),
item: $(".article-list li").toArray().map((elem) => ({
link: new URL($("a", elem).attr("href"), link).href,
title: $(".article-title", elem).text(),
pubDate: timezone(parseDate($(".article-date", elem).text()), 8)
}))
};
}
//#endregion
export { route };