UNPKG

rsshub

Version:
53 lines (52 loc) 1.79 kB
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/bwu/news.ts const route = { path: "/news", categories: ["university"], example: "/bwu/news", name: "通知公告", maintainers: ["muxinqi"], description: `::: warning 由于学校官网对非大陆 IP 的访问存在限制,需自行部署。 :::`, handler }; async function handler() { const title = "通知公告"; const host = "https://news.bwu.edu.cn/"; const $ = load(await rofetch("https://news.bwu.edu.cn/tzgg.htm")); const list = $("div[class=subPage] div ul li").toArray().slice(0, 25).map((item) => { const $item = $(item); const aTag = $item.find("a"); const link = new URL(aTag.attr("href"), host).href; return { title: aTag.text(), link, guid: link, pubDate: timezone(parseDate($item.find("span[class=rightDate]").text(), "YYYY-MM-DD"), 8) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { if (item.link.includes("shouye_content.jsp")) return item; const $detail = load(await rofetch(item.link)); const author = $detail("div[class=articleAuthor] p span").eq(1).text() || "null"; const authorName = author.includes(":") ? author.split(":", 2)[1].trim() : author; return { ...item, description: $detail("div[id^=vsb_content]").html(), author: `xcb@bwu.edu.cn (${authorName})` }; }))); return { title: `${title} - 物院新闻`, link: "https://news.bwu.edu.cn/tzgg.htm", description: `${title} - 北京物资学院新闻中心`, item: items }; } //#endregion export { route };