UNPKG

rsshub

Version:
55 lines (53 loc) 1.75 kB
import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./proxy-CjvoY5ys.mjs"; import "./puppeteer-9J9JS5H4.mjs"; import { n as puppeteerGet, t as baseURL } from "./utils-CaKIDqyx.mjs"; import { load } from "cheerio"; //#region lib/routes/alternativeto/platform.ts const route = { path: "/platform/:name/:routeParams?", categories: ["programming"], example: "/alternativeto/platform/firefox", parameters: { name: "Platform name", routeParams: "Filters of software type" }, features: { requireConfig: false, requirePuppeteer: true, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.alternativeto.net/platform/:name"], target: "/platform/:name" }], name: "Platform Software", maintainers: ["JimenezLi"], handler, description: `> routeParms can be copied from original site URL, example: \`/alternativeto/platform/firefox/license=free\`` }; async function handler(ctx) { const link = `https://alternativeto.net/platform/${ctx.req.param("name")}/?${new URLSearchParams(ctx.req.param("routeParams")).toString()}`; const $ = load(await puppeteerGet(link, cache_default)); return { title: $(".Heading_h1___Cf5Y").text().trim(), description: $(".intro-text").text().trim(), link, item: $(".AppListItem_appInfo__h9cWP").toArray().map((element) => { const item = $(element); return { title: item.find(".Heading_h2___LwQD").text().trim(), link: `${baseURL}${item.find(".Heading_h2___LwQD a").attr("href")}`, description: item.find(".AppListItem_description__wtODK").text().trim() }; }) }; } //#endregion export { route };