rsshub
Version:
Make RSS Great Again!
54 lines (53 loc) • 1.75 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as PRESETS } from "./header-generator-DACPoxdp.mjs";
import { t as got_default } from "./got-BTowW50G.mjs";
//#region lib/routes/xueqiu/snb.ts
const route = {
path: "/snb/:id",
categories: ["finance"],
example: "/xueqiu/snb/ZH1288184",
parameters: { id: "组合代码, 可在组合主页 URL 中找到." },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["xueqiu.com/P/:id", "xueqiu.com/p/:id"] }],
name: "组合最新调仓信息",
maintainers: ["ZhishanZhang"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const url = "https://xueqiu.com/p/" + id;
const data = (await got_default(url, { headerGeneratorOptions: PRESETS.MODERN_ANDROID })).data;
const info = /SNB.cubeInfo = \{(.+)\}/.exec(data);
const obj = JSON.parse("{" + info[1] + "}");
const rebalancing_histories = obj.sell_rebalancing.rebalancing_histories;
const snb_title = obj.name + " 的调仓历史";
const snb_description = obj.description;
const title = obj.name + " 的上一笔调仓";
let description = "";
for (const some_detail of rebalancing_histories) {
const prev_weight_adjusted = some_detail.prev_weight_adjusted ?? 0;
description += some_detail.stock_name + " from " + prev_weight_adjusted + " to " + some_detail.target_weight + ",\n";
}
const time = obj.sell_rebalancing.updated_at;
return {
title: snb_title,
link: url,
description: snb_description,
item: [{
title,
description,
pubDate: parseDate(time),
link: url,
guid: `xueqiu::snb::${id}::${time}`
}]
};
}
//#endregion
export { route };