UNPKG

rsshub

Version:
65 lines (63 loc) 2.45 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { t as config_not_found_default } from "./config-not-found-Dyp3RlZZ.mjs"; import { t as getHeaders } from "./utils-BXkxCuHO.mjs"; import { load } from "cheerio"; //#region lib/routes/smzdm/article.ts const route = { path: "/article/:uid", categories: ["shopping"], example: "/smzdm/article/6902738986", parameters: { uid: "用户 id,网址上直接可以看到" }, features: { requireConfig: [{ name: "SMZDM_COOKIE", description: "什么值得买登录后的 Cookie 值" }], requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["zhiyou.smzdm.com/member/:uid/article"] }], name: "用户文章", maintainers: ["xfangbao"], handler }; async function handler(ctx) { if (!config.smzdm.cookie) throw new config_not_found_default("什么值得买排行榜 is disabled due to the lack of SMZDM_COOKIE"); const link = `https://zhiyou.smzdm.com/member/${ctx.req.param("uid")}/article/`; const $ = load((await got_default(link, { headers: getHeaders() })).data); const title = $(".info-stuff-nickname a").text(); const list = $(".pandect-content-stuff").toArray().map((item) => { item = $(item); return { title: item.find(".pandect-content-title a").text(), link: item.find(".pandect-content-title a").attr("href"), pubDate: timezone(parseDate(item.find(".pandect-content-time").text(), ["YYYY-MM-DD", "MM-DD HH:mm"]), 8) }; }); const out = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load((await got_default(item.link, { headers: getHeaders() })).data); item.description = $$1(".m-contant article").html(); item.pubDate = timezone(parseDate($$1("meta[property=\"og:release_date\"]").attr("content"), "YYYY-MM-DD HH:mm:ss"), 8); item.author = $$1("meta[property=\"og:author\"]").attr("content"); return item; }))); return { title: `${title}-什么值得买`, link, item: out }; } //#endregion export { route };