rsshub
Version:
Make RSS Great Again!
66 lines (64 loc) • 2.13 kB
JavaScript
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 { 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 $ = load((await got_default(item)).data);
const description = $("#divArtBody").html();
return {
title: $("#h_title").text(),
link: item,
description,
pubDate: timezone(parseDate($("#pubtime_baidu").text().split("• ")[1], "YYYY-MM-DD HH:mm:ss"), 8),
author: $(".bljjxue").text().match(/\S+/)[0],
category: $("meta[name=\"Keywords\"]").attr("content").split(",")
};
})));
return {
title: `前瞻经济学人 - ${titles[type]}`,
link: rootUrl,
item: items
};
}
//#endregion
export { route };