UNPKG

rsshub

Version:
65 lines (63 loc) 2.07 kB
import { n as init_esm_shims, t as __dirname } from "./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 art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { n as rootUrl, t as getSearchParams } from "./utils-BwpBAMuc.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/cls/hot.ts init_esm_shims(); const route = { path: "/hot", categories: ["finance"], example: "/cls/hot", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["cls.cn/"] }], name: "热门文章排行榜", maintainers: ["5upernova-heng", "nczitzk"], handler, url: "cls.cn/" }; async function handler(ctx) { const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 50; let items = (await got_default({ method: "get", url: `${rootUrl}/v2/article/hot/list`, searchParams: getSearchParams() })).data.data.slice(0, limit).map((item) => ({ title: item.title || item.brief, link: `${rootUrl}/detail/${item.id}`, pubDate: parseDate(item.ctime * 1e3) })); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); const articleDetail = JSON.parse(content("script#__NEXT_DATA__").text()).props.initialState.detail.articleDetail; item.author = articleDetail.author?.name ?? item.author ?? ""; item.description = art(path.join(__dirname, "templates/depth-39e6d921.art"), { articleDetail }); return item; }))); return { title: "财联社 - 热门文章排行榜", link: rootUrl, item: items }; } //#endregion export { route };