UNPKG

rsshub

Version:
47 lines (46 loc) 1.7 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/jlbtc/index.ts const route = { path: "/:category?", categories: ["university"], example: "/jlbtc", parameters: { category: "分类,见下表,默认为通知公告" }, name: "主页", maintainers: ["nczitzk"], description: `| 工商要闻 | 工商动态 | 学术动态 | 通知公告 | 工商融媒 | | -------- | -------- | -------- | -------- | -------- | | gstt | gsdt | gsxs | tzggnew | gsfc |`, handler }; async function handler(ctx) { const { category = "tzggnew" } = ctx.req.param(); const currentUrl = `https://www.jlbtc.edu.cn/sylm/${category}.htm`; const response = await rofetch(currentUrl); const $ = load(response); const list = $(".newslisttitle").toArray().map((item) => { const $item = $(item); const a = $item.find(".newslisttitlex a"); return { title: a.text(), link: new URL(a.attr("href"), currentUrl).href, pubDate: timezone(parseDate($item.find(".wapnewsdate").text()), 8), description: $item.find(".newslisttitlexx").text() }; }); const items = await Promise.all(list.map((item) => item.link.startsWith("https://www.jlbtc.edu.cn/") ? cache_default.tryGet(item.link, async () => { const detailResponse = await rofetch(item.link); item.description = load(detailResponse)(".v_news_content").html(); return item; }) : item)); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };