UNPKG

rsshub

Version:
76 lines (74 loc) 2.53 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { Fragment, jsx } from "hono/jsx/jsx-runtime"; import { load } from "cheerio"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/gov/csrc/news.tsx const route = { path: "/csrc/news/:suffix{.+}?", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const baseUrl = "http://www.csrc.gov.cn"; const { suffix = "c100028/common_xq_list.shtml" } = ctx.req.param(); const link = `${baseUrl}/csrc/${suffix}`; const { data: res } = await got_default(link); const $ = load(res); const channelId = $("meta[name=\"channelid\"]").attr("content"); let data, out = []; if (channelId) { data = await got_default(`${baseUrl}/searchList/${channelId}`, { searchParams: { _isAgg: true, _isJson: true, _pageSize: 18, _template: "index", _rangeTimeGte: "", _channelName: "", page: 1 } }); out = data.data.data.results.map((item) => ({ title: item.title, description: (item.contentHtml ?? "") + renderToString(/* @__PURE__ */ jsx(Fragment, { children: item.resList?.map((attachment) => { return /* @__PURE__ */ jsx("a", { href: attachment.filePath?.startsWith("/") ? `${baseUrl}${attachment.filePath}` : attachment.filePath, children: attachment.fileName }, `${attachment.fileName}-${attachment.filePath}`); }) })), pubDate: parseDate(item.publishedTime, "x"), link: item.url })); } else { const list = $("#list li").toArray().map((item) => { item = $(item); const a = item.find("a"); return { title: a.text(), link: `${baseUrl}${a.attr("href")}`, pubDate: timezone(parseDate(item.find(".data").text(), "YYYY-MM-DD"), 8) }; }); out = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: res } = await got_default(item.link); item.description = load(res)(".detail-news").html(); return item; }))); } return { title: `中国证券监督管理委员会 - ${data?.data.channelName || $("head title").text()}`, link, image: "http://www.csrc.gov.cn/favicon.ico", item: out }; } //#endregion export { route };