UNPKG

rsshub

Version:
60 lines (58 loc) 2.24 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as fetchArticle } from "./wechat-mp-Dq_pp853.mjs"; import { load } from "cheerio"; //#region lib/routes/sjtu/yzb/zkxx.ts const baseTitle = "上海交通大学研究生招生网招考信息"; const baseUrl = "https://yzb.sjtu.edu.cn/index/zkxx/"; const route = { path: "/yzb/zkxx/:type", categories: ["university"], example: "/sjtu/yzb/zkxx/sszs", parameters: { type: "无默认选项" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "研究生招生网招考信息", maintainers: ["stdrc"], handler, description: `| 博士招生 | 硕士招生 | 港澳台招生 | 考点信息 | 院系动态 | | -------- | -------- | ---------- | -------- | -------- | | bszs | sszs | gatzs | kdxx | yxdt |` }; async function handler(ctx) { const pageUrl = `${baseUrl}${ctx.req.param("type")}.htm`; const $ = load(await ofetch_default(pageUrl)); const list = $("li[id^=\"line\"] a").toArray().map((elem) => ({ link: new URL(elem.attribs.href, pageUrl).href, title: $(elem).text(), pubDate: parseDate($(elem.next?.next).text().trim()) })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { if (new URL(item.link).hostname === "mp.weixin.qq.com") return await fetchArticle(item.link); else if (new URL(item.link).hostname === "www.shmeea.edu.cn") { item.description = load(await ofetch_default(item.link.replace("http://", "https://")))(".Article_content").html(); return item; } else if (new URL(item.link).hostname === "yzb.sjtu.edu.cn") { item.description = load(await ofetch_default(item.link))("[id^=vsb_content]").html(); return item; } else return item; }))); return { link: pageUrl, title: `${baseTitle} -- ${$("title").text().split("-")[0]}`, item: items }; } //#endregion export { route };