rsshub
Version:
Make RSS Great Again!
60 lines (58 loc) • 1.63 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
//#region lib/routes/jd/price.ts
init_esm_shims();
const route = {
path: "/price/:id",
categories: ["shopping"],
example: "/jd/price/526835",
parameters: { id: "商品 id,可在商品详情页 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "商品价格",
maintainers: ["nczitzk"],
handler,
description: `::: tip
如商品 \`https://item.jd.com/526835.html\` 中的 id 为 \`526835\`,所以路由为 [\`/jd/price/526835\`](https://rsshub.app/jd/price/526835)
:::`
};
async function handler(ctx) {
const id = ctx.req.param("id");
const currentUrl = `https://item.jd.com/${id}.html`;
const data = (await got_default({
method: "get",
url: `http://p.3.cn/prices/mgets?skuIds=J_${id}`
})).data[0];
return {
title: `京东商品价格 - ${(await got_default({
method: "get",
url: currentUrl
})).data.match(/name: '(.*?)'/)[1]}`,
link: currentUrl,
item: [{
guid: data.p,
title: data.p,
link: currentUrl,
description: art(path.join(__dirname, "templates/description-c5f749f8.art"), {
p: data.p,
op: data.op,
m: data.m
})
}]
};
}
//#endregion
export { route };