UNPKG

rsshub

Version:
54 lines (52 loc) 1.74 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 { r as getSubPath } from "./common-utils-vrWQFAEk.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/web3caff/index.ts const route = { path: "*", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const currentUrl = `https://web3caff.com${getSubPath(ctx) === "/" ? "" : getSubPath(ctx)}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".list-grouped").first().find(".list-body").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 10).toArray().map((item) => { item = $(item); const a = item.find(".list-title"); return { title: a.text(), link: a.attr("href") }; }); 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); content(".ss-inline-share-wrapper").remove(); item.description = content(".post-content").html(); item.author = content(".author-name .author-popup").text(); item.category = content("a[rel=\"category tag\"]").toArray().map((tag) => $(tag).text()); item.pubDate = parseDate(content("meta[property=\"article:published_time\"]").attr("content")); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };