UNPKG

rsshub

Version:
81 lines (79 loc) 2.37 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/bupt/scss.ts const route = { path: "/scss/tzgg", categories: ["university"], example: "/bupt/scss/tzgg", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["scss.bupt.edu.cn/index/tzgg1.htm"], target: "/scss/tzgg" }], name: "网络空间安全学院 - 通知公告", maintainers: ["ziri2004"], handler, url: "scss.bupt.edu.cn" }; async function handler() { const rootUrl = "https://scss.bupt.edu.cn"; const currentUrl = `${rootUrl}/index/tzgg1.htm`; const pageTitle = "通知公告"; const selector = ".Newslist li"; const $ = load((await got_default({ method: "get", url: currentUrl })).data); const list = $(selector).toArray().map((item) => { const $item = $(item); const $link = $item.find("a"); if ($link.length === 0 || !$link.attr("href")) return null; const link = new URL($link.attr("href"), rootUrl).href; const rawDate = $item.find("span").text().replace("发布时间:", "").trim(); return { title: $link.text().trim(), link, pubDateRaw: rawDate }; }).filter(Boolean); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); const newsContent = content(".v_news_content"); newsContent.find("p, span, strong").each(function() { const element = content(this); const text = element.text().trim(); if (text === "") element.remove(); else element.replaceWith(text); }); item.description = newsContent.text(); item.pubDate = timezone(parseDate(item.pubDateRaw), 8); return item; }))); return { title: `北京邮电大学网络空间安全学院 - ${pageTitle}`, link: currentUrl, item: items }; } //#endregion export { route };