UNPKG

rsshub

Version:
74 lines (71 loc) 2.47 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/njucm/utils/index.ts async function getNoticeList(ctx, url$1, host$1, listSelector, titleSelector, contentSelector) { const $ = load((await got_default(url$1)).data); const list = $(listSelector).toArray().map((item) => { item = $(item); return { title: item.find(titleSelector).attr("title"), link: host$1 + item.find(titleSelector).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(); item.pubDate = timezone(parseDate($$1(contentSelector.date).text()), 8); } return item; }))); } //#endregion //#region lib/routes/njucm/grabs.ts const url = "https://gra.njucm.edu.cn/2899/list.htm"; const host = "https://gra.njucm.edu.cn"; const route = { path: "/grabszs", categories: ["university"], example: "/njucm/grabszs", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["lib.njucm.edu.cn/2899/list.htm", "lib.njucm.edu.cn/"] }], name: "研究生院博士招生", maintainers: ["real-jiakai"], handler, url: "lib.njucm.edu.cn/2899/list.htm" }; async function handler(ctx) { return { title: "南京中医药大学 -- 博士招生", link: url, item: await getNoticeList(ctx, url, host, "#wp_news_w3 > table > tbody > tr", "a", { title: ".Article_Title", content: ".Article_Content", date: ".Article_PublishDate" }) }; } //#endregion export { route };