UNPKG

rsshub

Version:
75 lines (73 loc) 2.36 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 getPageItemAndDate } from "./utils-glX0MsEd.mjs"; import { load } from "cheerio"; //#region lib/routes/jsu/cxzx.ts const route = { path: "/cxzx/:types?", name: "Unknown", maintainers: ["wenjia03"], handler }; async function handler(ctx) { const { types = "xkjs" } = ctx.req.param(); const baseUrl = "https://cxzx.jsu.edu.cn/"; const urls = { tzgg: { url: "https://cxzx.jsu.edu.cn/xwzx.htm", title: "通知公告" }, xkjs: { url: "https://cxzx.jsu.edu.cn/xwzx/zxdt.htm", title: "学科竞赛公告" }, cxtz: { url: "https://cxzx.jsu.edu.cn/cxlt/xsjz1.htm", title: "创新项目公告" }, jsxw: { url: "https://cxzx.jsu.edu.cn/cxjs.htm", title: "竞赛新闻" }, jstz: { url: "https://cxzx.jsu.edu.cn/cxjs/xkjs.htm", title: "竞赛新闻 -> 通知公告" } }; const $ = load((await got_default({ method: "get", url: urls[types].url })).data); const list = $("tr[height=\"20\"]").toArray(); const out = await Promise.all(list.map((item) => { item = $(item); const link = new URL(item.find("td:nth-child(2) > a").attr("href"), baseUrl).href; return cache_default.tryGet(link, async () => { const title = item.find("td:nth-child(2) > a").text() || "无标题"; const category = urls[types].title; const description = await getPageItemAndDate("#vsb_newscontent", link, "body > div.cx_big_container > div.cx_content_container > div.cx_right_part > div.viewbox > form > table > tbody > tr:nth-child(1) > td", "body > div.cx_big_container > div.cx_content_container > div.cx_right_part > div.viewbox > form > table > tbody > tr:nth-child(2) > td > span.timestyle134612"); return { title, link, pubDate: parseDate(description.date), description: description.pageInfo, category }; }); })); return { title: `吉首大学创新中心 - ${urls[types].title}`, link: urls[types].url, description: "吉首大学创新中心", item: out }; } //#endregion export { route };