UNPKG

rsshub

Version:
75 lines (72 loc) 2.54 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/njglyy/utils/index.ts async function getNoticeList(ctx, url$1, host$1, listSelector, itemSelector, titleSelector, contentSelector) { const $ = load((await got_default(url$1)).data); const list = $(listSelector).toArray().map((item) => { item = $(item); return { title: item.find(titleSelector).text(), link: host$1 + item.find(itemSelector).attr("href") }; }); return await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const response = await got_default(item.link); if (response.redirectUrls.length) { item.link = response.redirectUrls[0]; item.description = "该通知无法直接预览,请点击原文链接↑查看"; } else { const $$1 = load(response.data); item.title = $$1(contentSelector.title).text(); item.description = $$1(contentSelector.content).html().replaceAll("src=\"/", `src="${new URL(".", host$1).href}`).replaceAll("href=\"/", `href="${new URL(".", host$1).href}`).trim(); const preDate = $$1(contentSelector.date).text().match(/(\d{4}-\d{2}-\d{2})/)[1]; item.pubDate = timezone(parseDate(preDate, "YYYY-MM-DD"), 8); } return item; }))); } //#endregion //#region lib/routes/njglyy/ygbjypx.ts const url = "https://njglyy.com/ygb/jypx/jypx.aspx"; const host = "https://njglyy.com/ygb/jypx/"; const route = { path: "/ygbjypx", categories: ["government"], example: "/njglyy/ygbjypx", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["njglyy.com/ygb/jypx/jypx.aspx", "njglyy.com/"] }], name: "员工版教育培训", maintainers: ["real-jiakai"], handler, url: "njglyy.com/ygb/jypx/jypx.aspx" }; async function handler(ctx) { return { title: "南京鼓楼医院 -- 员工版教育培训", link: url, item: await getNoticeList(ctx, url, host, ".mtbd-list > dl", "a", "dt", { title: ".detail", content: ".detail2", date: "span:contains(\"发布时间\")" }) }; } //#endregion export { route };