UNPKG

rsshub

Version:
81 lines (79 loc) 2.53 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 { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { load } from "cheerio"; //#region lib/routes/ustc/eeis.ts const map = new Map([["tzgg", { title: "中国科学技术大学电子工程与信息科学系 - 通知公告", id: "2702" }], ["xwxx", { title: "中国科学技术大学电子工程与信息科学系 - 新闻信息", id: "2706" }]]); const host = "https://eeis.ustc.edu.cn"; const route = { path: "/eeis/:type?", categories: ["university"], example: "/ustc/eeis/tzgg", parameters: { type: "分类,见下表,默认为通知公告" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["eeis.ustc.edu.cn/"], target: "/eeis" }], name: "电子工程与信息科学系", maintainers: ["jasongzy"], handler, url: "eeis.ustc.edu.cn/", description: `| 通知公告 | 新闻信息 | | -------- | -------- | | tzgg | xwxx |` }; async function handler(ctx) { const type = ctx.req.param("type") ?? "tzgg"; const info = map.get(type); if (!info) throw new invalid_parameter_default("invalid type"); const id = info.id; const $ = load((await got_default(`${host}/${id}/list.htm`)).data); const list = $("div[portletmode=simpleList]").find("article").toArray().map((item) => { item = $(item); const title = item.find("h4 > a").eq(1).attr("title").trim(); let link = item.find("h4 > a").attr("href"); link = link.startsWith("/") ? host + link : link; return { title, pubDate: timezone(parseDate(item.find(".post-date > time").text().replace("发布时间:", ""), "YYYY-MM-DD"), 8), link }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { let desc = ""; try { desc = load((await got_default(item.link)).data)("div.wp_articlecontent").html(); item.description = desc; } catch {} return item; }))); return { title: info.title, link: `${host}/${id}/list.htm`, item: items }; } //#endregion export { route };