UNPKG

rsshub

Version:
66 lines (64 loc) 2.49 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 { n as finishArticleItem } from "./wechat-mp-Dq_pp853.mjs"; import { load } from "cheerio"; //#region lib/routes/hrbeu/uae/news.ts const route = { path: "/uae/:id", categories: ["university"], example: "/hrbeu/uae/xwdt", parameters: { id: "栏目编号,在 `URL` 中获取,如果有多级编号,将 `/` 替换为 `-`。" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["uae.hrbeu.edu.cn/:id.htm"] }], name: "水声工程学院", maintainers: [], handler, description: `| 新闻动态 | 通知公告 | 科学研究 / 科研动态 | | :------: | :------: | :-----------------: | | xwdt | tzgg | kxyj-kydt |` }; async function handler(ctx) { const id = ctx.req.param("id").replaceAll("-", "/"); const host = "http://uae.hrbeu.edu.cn"; const url = `${host}/${id}.htm`; const $ = load((await got_default(url, { headers: { Referer: host } })).data); const title = $("h2").text(); const items = $("li.wow.fadeInUp").toArray().map((item$1) => { const title$1 = $(item$1).find("a").attr("title"); let link = $(item$1).find("a").attr("href"); if (!link.startsWith("http")) link = `${host}/${link}`; return { title: title$1, pubDate: parseDate($(item$1).find("div.date").text().replaceAll(/(.*)\/(.*)/g, "$2-$1")), link }; }); const item = await Promise.all(items.map((item$1) => cache_default.tryGet(item$1.link, async () => { if (new URL(item$1.link).hostname === "uae.hrbeu.edu.cn") item$1.description = load((await got_default(item$1.link)).data)("div.art-body").html(); else if (new URL(item$1.link).hostname === "news.hrbeu.edu.cn") item$1.description = load((await got_default(item$1.link)).data)("div#print").html(); else if (new URL(item$1.link).hostname === "mp.weixin.qq.com") await finishArticleItem(item$1); else item$1.description = "本文需跳转,请点击标题后阅读"; return item$1; }))); return { title: `水声工程学院 - ${title}`, link: url, item }; } //#endregion export { route };