UNPKG

rsshub

Version:
55 lines (53 loc) 1.82 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./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 { i as parseReviews, n as fixImages, r as headers, t as baseUrl } from "./utils-CbAT-uBf.mjs"; import { load } from "cheerio"; //#region lib/routes/techpowerup/index.ts const route = { path: "/", radar: [{ source: ["techpowerup.com/"] }], name: "Latest Content", maintainers: ["TonyRL"], example: "/techpowerup", handler, url: "www.techpowerup.com/" }; async function handler() { const $ = load(await ofetch_default(baseUrl, { headers })); const list = $(".newspost").toArray().map((item) => { const $item = $(item); const a = $item.find("h1 a"); const date = $item.find("time").attr("datetime"); return { title: a.text(), link: baseUrl + a.attr("href"), pubDate: date ? parseDate(date) : null, author: $item.find(".byline address").text(), category: $item.find(".byline .flags span").toArray().map((item) => $(item).text().trim()) }; }); return { title: "TechPowerUp", link: baseUrl, language: "en", image: "https://tpucdn.com/apple-touch-icon-v1684568903519.png", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load(await ofetch_default(item.link, { headers })); fixImages($); if (item.link.includes("/review/")) { await parseReviews($, item); return item; } item.description = $(".newspost .text").html(); item.category = [...new Set([...item.category, ...$(".tags li a").toArray().map((item) => $(item).text())])]; return item; }))) }; } //#endregion export { route };