rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.63 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/jlbtc/index.ts
const route = {
path: "/:category?",
categories: ["university"],
example: "/jlbtc",
parameters: { category: "分类,见下表,默认为通知公告" },
name: "主页",
maintainers: ["nczitzk"],
description: `| 工商要闻 | 工商动态 | 学术动态 | 通知公告 | 工商融媒 |
| -------- | -------- | -------- | -------- | -------- |
| gstt | gsdt | gsxs | tzggnew | gsfc |`,
handler
};
async function handler(ctx) {
const { category = "tzggnew" } = ctx.req.param();
const currentUrl = `https://www.jlbtc.edu.cn/sylm/${category}.htm`;
const $ = load(await rofetch(currentUrl));
const list = $(".newslisttitle").toArray().map((item) => {
const $item = $(item);
const a = $item.find(".newslisttitlex a");
return {
title: a.text(),
link: new URL(a.attr("href"), currentUrl).href,
pubDate: timezone(parseDate($item.find(".wapnewsdate").text()), 8),
description: $item.find(".newslisttitlexx").text()
};
});
const items = await Promise.all(list.map((item) => item.link.startsWith("https://www.jlbtc.edu.cn/") ? cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))(".v_news_content").html();
return item;
}) : item));
return {
title: $("title").text(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };