UNPKG

rsshub

Version:
52 lines (51 loc) 1.72 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { n as parseArticle, t as baseUrl } from "./utils-BejjiEQ1.mjs"; import { load } from "cheerio"; //#region lib/routes/agirls/z-index.ts const route = { path: "/:category?", categories: ["new-media"], example: "/agirls/app", parameters: { category: "分类,默认为最新文章,可在对应主题页的 URL 中找到,下表仅列出部分" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["agirls.aotter.net/posts/:category"], target: "/:category" }], name: "分类", maintainers: ["TonyRL"], handler, description: `| App 评测 | 手机开箱 | 笔电开箱 | 3C 周边 | 教学小技巧 | 科技情报 | | -------- | -------- | -------- | ----------- | ---------- | -------- | | app | phone | computer | accessories | tutorial | techlife |` }; async function handler(ctx) { const { category = "" } = ctx.req.param(); const link = `${baseUrl}/posts${category ? `/${category}` : ""}`; const $ = load(await rofetch(link)); const list = $(".ag-post-list .ag-post-item__link").toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: `${baseUrl}${$item.attr("href")}` }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, () => parseArticle(item)))); return { title: $("head title").text(), link, description: $("head meta[name=description]").attr("content"), item: items, language: $("html").attr("lang") }; } //#endregion export { route };