UNPKG

rsshub

Version:
52 lines (51 loc) 1.71 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { i as parseReviews, n as fixImages, r as headers, t as baseUrl } from "./utils-BKIm93gM.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/" }; const language = "en"; async function handler() { const $ = load(await rofetch(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()) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load(await rofetch(item.link, { headers })); fixImages($); if (item.link.includes("/review/")) { await parseReviews($, item); return item; } item.description = $(".newspost .text").html(); item.category = [.../* @__PURE__ */ new Set([...item.category, ...$(".tags li a").toArray().map((item) => $(item).text())])]; return item; }))); return { title: "TechPowerUp", link: baseUrl, language, image: "https://tpucdn.com/apple-touch-icon-v1684568903519.png", item: items }; } //#endregion export { route };