UNPKG

rsshub

Version:
47 lines (45 loc) 1.88 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 { load } from "cheerio"; //#region lib/routes/caixin/weekly.ts const route = { path: "/weekly", categories: ["traditional-media"], example: "/caixin/weekly", radar: [{ source: ["weekly.caixin.com/", "weekly.caixin.com/*"] }], name: "财新周刊", maintainers: ["TonyRL"], handler, url: "weekly.caixin.com/" }; async function handler(ctx) { const link = "https://weekly.caixin.com"; const { data: response } = await got_default(link); const $ = load(response); const list = [...$(".mi").toArray().map((item) => ({ link: $(item).find("a").attr("href")?.replace("http:", "https:") })), ...$(".xsjCon a").toArray().map((item) => ({ link: $(item).attr("href") }))].slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 10); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data } = await got_default(item.link); const $$1 = load(data); item.title = $$1("head title").text().replace(/_财新周刊频道_财新网$/, "").trim(); item.pubDate = parseDate($$1(".source").text().match(/出版日期:(\d{4}-\d{2}-\d{2})/)[1]); $$1(".subscribe").remove(); const report = $$1(".report"); report.find(".title, .source, .date").remove(); item.description = $$1(".cover").html() + report.html() + $$1(".magIntro2").html(); return item; }))); return { title: $("head title").text().replace(/_财新周刊频道_财新网$/, "").trim(), link, item: items }; } //#endregion export { route };