rsshub
Version:
Make RSS Great Again!
41 lines (40 loc) • 1.31 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/cqust/lib.ts
const route = {
path: "/lib/:type?",
categories: ["university"],
example: "/cqust/lib/news",
parameters: { type: "可选,默认为 `news`" },
name: "图书馆公告",
maintainers: ["binarization"],
description: `| 本馆公告 |
| -------- |
| news |`,
handler
};
const host = "http://lib.cqust.edu.cn";
const map = { news: "/node/410.jspx" };
async function handler(ctx) {
const { type = "news" } = ctx.req.param();
const link = host + map[type];
const $ = load(await rofetch(link, { headers: { Cookie: `JSESSIONID=${Math.random()}` } }));
return {
title: "重科图书馆",
link,
description: $("meta[name=\"description\"]").attr("content") || "重科图书馆公告",
item: $("div[class=\"newsList\"] li").toArray().slice(0, 10).map((item) => {
const $item = $(item);
return {
title: $item.find("a").text(),
description: "重科图书馆公告",
pubDate: timezone(parseDate($item.find("span[class=\"time\"]").text()), 8),
link: new URL($item.find("a").attr("href"), host).href
};
})
};
}
//#endregion
export { route };