Files
ObsidianHome/小鱼/.cdp/ov-struct.mjs
T

35 lines
1.1 KiB
JavaScript

import fs from 'node:fs';
const j = JSON.parse(fs.readFileSync('.cdp/out/overview-capture.json', 'utf8'));
const bodies = j.value.rawBodies;
// 只取 seller.summary
const sellers = [];
for (const b of bodies) {
if (!/singleuser\.seller\.summary/.test(b.url)) continue;
const p = JSON.parse(b.text);
const d = p && p.data && p.data.data;
if (!d) continue;
const t = Number((/t=(\d+)/.exec(b.url) || [])[1] || 0);
sellers.push({ t, d });
}
sellers.sort((a, b) => a.t - b.t);
const L = [];
L.push('seller.summary 响应数: ' + sellers.length);
for (const s of sellers) {
const d = s.d;
L.push('\n===== t=' + s.t + ' =====');
L.push('keys: ' + JSON.stringify(Object.keys(d)));
const ext = d.extendInfo || {};
L.push('extendInfo: ' + JSON.stringify(ext).slice(0, 600));
const g = d.graphDataList;
if (Array.isArray(g)) {
L.push('graphDataList len=' + g.length);
L.push('第一项 keys: ' + JSON.stringify(Object.keys(g[0])));
L.push('最后一项: ' + JSON.stringify(g[g.length - 1]));
} else {
L.push('graphDataList: ' + String(g));
}
}
fs.writeFileSync('.cdp/out/ov-structure.txt', L.join('\n'), 'utf8');