UNPKG

rsshub

Version:
44 lines (43 loc) 1.46 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/moxingfans/index.ts const route = { path: "/", categories: ["other"], example: "/moxingfans", name: "新品信息", maintainers: ["cc798461"], handler }; async function handler() { const baseUrl = "http://www.moxingfans.com/"; const cookie = (await rofetch.raw(`${baseUrl}new`, { ignoreResponseError: true })).headers.getSetCookie().map((c) => c.split(";", 1)[0]).join("; "); const response = await rofetch(`${baseUrl}new`, { headers: { cookie } }); const $ = load(response); return { title: "静态模型爱好者", link: baseUrl, item: await Promise.all($("article").toArray().map((item) => { const $a = $(item).find("header > h2 > a"); const href = $a.attr("href"); if (!href) return; const link = new URL(href, baseUrl).href; const title = $a.text(); return cache_default.tryGet(link, async () => { const detailResponse = await rofetch(link, { headers: { cookie } }); const $$ = load(detailResponse); return { title, description: $$("article.article-content").html(), link, pubDate: timezone(parseDate($$("time").text()), 8) }; }); }).filter((v) => v !== void 0)) }; } //#endregion export { route };