UNPKG

rsshub

Version:
87 lines (80 loc) 3.52 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 { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { t as isValidHost } from "./valid-host-DqbCYAHY.mjs"; import "./article-A9018XNJ.mjs"; import { t as parseArticle } from "./utils-DjUPZNBE.mjs"; import { load } from "cheerio"; //#region lib/routes/caixin/category.ts const route = { path: "/:column/:category", categories: ["traditional-media"], example: "/caixin/finance/regulation", parameters: { column: "栏目名", category: "栏目下的子分类名" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: true, supportScihub: false }, name: "新闻分类", maintainers: ["idealclover"], handler, description: `Column 列表: | 经济 | 金融 | 政经 | 环科 | 世界 | 观点网 | 文化 | 周刊 | | ------- | ------- | ----- | ------- | ------------- | ------- | ------- | ------ | | economy | finance | china | science | international | opinion | culture | weekly | 以金融板块为例的 category 列表:(其余 column 以类似方式寻找) | 监管 | 银行 | 证券基金 | 信托保险 | 投资 | 创新 | 市场 | | ---------- | ---- | -------- | ---------------- | ---------- | ---------- | ------ | | regulation | bank | stock | insurance_trust | investment | innovation | market | Category 列表: | 封面报道 | 开卷 | 社论 | 时事 | 编辑寄语 | 经济 | 金融 | 商业 | 环境与科技 | 民生 | 副刊 | | ---------- | ----- | --------- | ---------------- | ------------ | ------- | ------- | -------- | ----------------------- | ------- | ------ | | coverstory | first | editorial | current_affairs | editor_desk | economy | finance | business | environment_technology | cwcivil | column |` }; async function handler(ctx) { const category = ctx.req.param("category"); const column = ctx.req.param("column"); const url = `https://${column}.caixin.com/${category}`; if (!isValidHost(column)) throw new invalid_parameter_default("Invalid column"); const $ = load((await got_default(url)).data); const title = $("head title").text(); const { data: { datas: data } } = await got_default("https://gateway.caixin.com/api/extapi/homeInterface.jsp", { searchParams: { subject: JSON.parse($("script").text().match(/var entity = ({.*?})/)[1]).id, type: 0, count: ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 25, picdim: "_266_177", start: 0 } }); const list = data.map((item) => ({ title: item.desc, description: item.summ, link: item.link.replace("http://", "https://"), pubDate: timezone(parseDate(item.time), 8), category: item.keyword.split(" "), audio: item.audioUrl, audio_image_url: item.pict.imgs[0].url })); return { title, link: url, description: "财新网 - 提供财经新闻及资讯服务", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, () => parseArticle(item)))) }; } //#endregion export { route };