UNPKG

rsshub

Version:
66 lines (64 loc) 2.15 kB
import "./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 got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/qianzhan/column.ts const route = { path: "/analyst/column/:type?", categories: ["finance"], example: "/qianzhan/analyst/column/all", parameters: { type: "分类,见下表" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "文章列表", maintainers: ["moke8"], handler, description: `| 全部 | 研究员专栏 | 规划师专栏 | 观察家专栏 | | ---- | ---------- | ---------- | ---------- | | all | 220 | 627 | 329 |` }; async function handler(ctx) { let rootUrl = "https://www.qianzhan.com/analyst/"; const titles = { all: "最新文章", 220: "研究员专栏", 627: "规划师专栏", 329: "观察家专栏" }; const { type = "all" } = ctx.req.param(); if (type !== "all") rootUrl = rootUrl + "list/" + type + ".html"; const $ = load((await got_default(rootUrl)).data); const links = $(".ptb30.bb1e.clf .f22 a").map((_, item) => $(item).attr("href")); const items = await Promise.all(links.map((_, item) => cache_default.tryGet(item, async () => { const $$1 = load((await got_default(item)).data); const description = $$1("#divArtBody").html(); return { title: $$1("#h_title").text(), link: item, description, pubDate: timezone(parseDate($$1("#pubtime_baidu").text().split("• ")[1], "YYYY-MM-DD HH:mm:ss"), 8), author: $$1(".bljjxue").text().match(/\S+/)[0], category: $$1("meta[name=\"Keywords\"]").attr("content").split(",") }; }))); return { title: `前瞻经济学人 - ${titles[type]}`, link: rootUrl, item: items }; } //#endregion export { route };