UNPKG

rsshub

Version:
69 lines (67 loc) 1.93 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/macfilos/blog.ts const route = { path: "/blog", categories: ["new-media"], example: "/macfilos/blog", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["macfilos.com/blog", "macfilos.com/"] }], name: "Blog", maintainers: ["nczitzk"], handler, url: "macfilos.com/blog" }; async function handler(ctx) { const currentUrl = `https://www.macfilos.com/blog`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".entry-title a").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 10).toArray().map((item) => { item = $(item); const parent = item.parent().parent(); return { title: item.text(), link: item.attr("href"), author: parent.find(".td-post-author-name a").text(), pubDate: parseDate(parent.find(".td-post-date time").attr("datetime")) }; }); 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("hr").nextAll().remove(); content("hr").remove(); content("img").each(function() { content(this).removeAttr("srcset"); }); item.description = content(".td-post-content").html(); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };