UNPKG

rsshub

Version:
70 lines (69 loc) 2.13 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { load } from "cheerio"; //#region lib/routes/swufe/seie.ts const listUrl = "https://it.swufe.edu.cn/index/"; const map = /* @__PURE__ */ new Map([["xyxw", { title: "西南财经大学经济信息工程学院 -- 学院新闻", suffix: "xyxw.htm" }], ["tzgg", { title: "西南财经大学经济信息工程学院 -- 通知公告", suffix: "tzgg.htm" }]]); const route = { path: "/seie/:type?", categories: ["university"], example: "/swufe/seie/tzgg", parameters: { type: "分类名,默认为 tzgg" }, radar: [{ source: ["it.swufe.edu.cn/index/tzgg.htm"], target: "/seie/tzgg" }, { source: ["it.swufe.edu.cn/index/xyxw.htm"], target: "/seie/xyxw" }], name: "经济信息工程学院", maintainers: ["Hivol"], handler, description: `| 学院新闻 | 通知公告 | | -------- | -------- | | xyxw | tzgg |` }; async function handler(ctx) { const { type = "tzgg" } = ctx.req.param(); const { title, suffix } = map.get(type); const link = listUrl + suffix; const $ = load(await rofetch(link)); const list = $(".article_list_item_content_title").toArray().map((elem) => { const $elem = $(elem); return { link: new URL($elem.find("a").attr("href"), link).href, title: $elem.find("a").text(), date: $elem.find("span").text() }; }); return { title, link, description: "西南财经大学经济信息工程学院RSS", item: await Promise.all(list.map((info) => cache_default.tryGet(info.link, async () => { const $ = load(await rofetch(info.link)); const content = $(".article-main"); content.find("img[orisrc]").each((_, img) => { const $img = $(img); $img.attr("src", $img.attr("orisrc")); $img.removeAttr("orisrc"); }); return { title: info.title, link: info.link, description: content.html().trim(), pubDate: timezone(parseDate(info.date), 8) }; }))) }; } //#endregion export { route };