UNPKG

rsshub

Version:
69 lines (67 loc) 2.27 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/shmtu/jwc.ts const host = "https://jwc.shmtu.edu.cn"; async function loadContent(link) { return load((await got_default(link, { https: { rejectUnauthorized: false } })).data)(".wp_articlecontent").html(); } const ProcessFeed = (list, caches) => Promise.all(list.map((item) => caches.tryGet(item.link, async () => { item.description = await loadContent(item.link); return item; }))); const route = { path: "/jwc/:type", categories: ["university"], example: "/shmtu/jwc/jwgg", parameters: { type: "类型名称" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["jwc.shmtu.edu.cn/:type"] }], name: "教务信息", maintainers: ["imbytecat", "simonsmh"], handler, description: `| 教务公告 | 教务新闻 | | -------- | -------- | | jwgg | jwxw |` }; async function handler(ctx) { const type = ctx.req.param("type"); const info = type === "jwgg" ? "教务公告" : "教务新闻"; const $ = load((await got_default(`${host}/${type}/list.htm`, { headers: { Referer: host }, https: { rejectUnauthorized: false } })).data); const result = await ProcessFeed($("tbody tr").toArray().map((item) => { item = $(item); return { title: item.find(".views-field-nothing a").attr("title").trim(), link: new URL(item.find("a").attr("href"), host).href, pubDate: timezone(parseDate(item.find(".pubdate").text()), 8), category: item.find(".views-field-field-xxlb").text(), author: item.find(".views-field-field-xxly").text() }; }), cache_default); return { title: `上海海事大学 ${info}`, link: `${host}/${type}`, description: "上海海事大学 教务信息", item: result }; } //#endregion export { route };