UNPKG

rsshub

Version:
49 lines (48 loc) 1.68 kB
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/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 response = await rofetch(url); const $ = load(response); 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 detailResponse = await rofetch(link); const $detail = load(detailResponse); 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 };