rsshub
Version:
Make RSS Great Again!
47 lines (46 loc) • 1.61 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/cqu/news-tz.ts
const route = {
path: "/news/tz",
categories: ["university"],
example: "/cqu/news/tz",
name: "新闻网通知公告简报",
maintainers: ["Hagb"],
handler
};
async function handler() {
const baseUrl = "https://news.cqu.edu.cn/";
const url = "https://news.cqu.edu.cn/archives/notice/index.html";
const $ = load(await rofetch(url));
const links = $("div[class=lists]", "div[class=\"container newslist\"]").find("div[class=\"content w100\"]").toArray().map((item) => {
const $item = $(item);
const a = $item.find("a[href]");
return {
title: a.text(),
link: new URL(a.attr("href"), baseUrl).href,
pubDate: timezone(parseDate($item.find("div[class=rdate]").attr("date")), 8)
};
});
const items = await Promise.all(links.map(({ title, link, pubDate }) => cache_default.tryGet(link, async () => {
const $detail = load(await rofetch(link));
const newsContent = $detail("div[class=content]", "div[class=\"container detail\"]");
return {
title,
link,
pubDate,
author: newsContent.find("p").find("a[href=\"javascript:;\"]").toArray().map((item) => $detail(item).text()).filter(Boolean).join("-"),
description: newsContent.find("div[class=acontent]").html()
};
})));
return {
title: $("title").text(),
link: url,
item: items
};
}
//#endregion
export { route };