rsshub
Version:
Make RSS Great Again!
42 lines (41 loc) • 1.25 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 { load } from "cheerio";
//#region lib/routes/cpu/home.ts
const route = {
path: "/home",
categories: ["university"],
example: "/cpu/home",
name: "最新公告",
maintainers: ["kba977"],
handler
};
async function handler() {
const baseUrl = "https://www.cpu.edu.cn";
const url = `${baseUrl}/4133/list.htm`;
const $ = load(await rofetch(url));
const list = $(".col_news_list li.news").toArray().map((item) => {
const $item = $(item);
const a = $item.find(".news_title a");
return {
title: a.attr("title") || a.text(),
link: new URL(a.attr("href"), baseUrl).href,
pubDate: parseDate($item.find(".news_meta").text())
};
});
return {
title: "中国药科大学 | 最新公告",
link: url,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
try {
const $ = load(await rofetch(item.link));
item.description = $(".wp_articlecontent").html() ?? $(".v_news_content").html();
} catch {}
return item;
}))),
description: "中国药科大学 | 最新公告"
};
}
//#endregion
export { route };