rsshub
Version:
Make RSS Great Again!
43 lines (42 loc) • 1.49 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { t as timezone } from "./timezone-UiMFOuvL.mjs";
import { load } from "cheerio";
//#region lib/routes/cug/undergraduate.ts
const route = {
path: "/undergraduate",
categories: ["university"],
example: "/cug/undergraduate",
name: "中国地质大学通知公告",
maintainers: ["chunibyo-wly"],
handler
};
async function handler() {
const baseUrl = "https://www.cug.edu.cn/index/tzgg.htm";
const response = await rofetch(baseUrl);
const $ = load(response);
const list = $(".xb-list li.xblist-oli");
return {
title: "中国地质大学(武汉) - 综合通知公告",
link: baseUrl,
item: await Promise.all(list.toArray().map((element) => {
const $element = $(element);
const link = new URL($element.find(".xblist-title a").attr("href"), baseUrl).href;
const item = {
title: $element.find(".xblist-title h2").text(),
link,
pubDate: timezone(parseDate(`${$element.find(".xblist-date p").text()}-${$element.find(".xblist-date h2").text()}`, "YYYY-MM-DD"), 8)
};
if (!new URL(link).hostname.endsWith("www.cug.edu.cn")) return item;
return cache_default.tryGet(link, async () => {
const result = await rofetch(link);
const $ = load(result);
item.description = $(".v_news_content").html();
return item;
});
}))
};
}
//#endregion
export { route };