#!/usr/bin/env node /** 快速查看 VOC JSON 数据结构 */ const fs = require('fs'); const path = require('path'); const files = ['jiangzhong-liver-voc.json', 'jiangzhong-probiotic-voc.json', 'jiangzhong-monkey-voc.json']; for (const f of files) { const full = path.join('data', f); if (!fs.existsSync(full)) continue; const j = JSON.parse(fs.readFileSync(full, 'utf-8')); console.log(''); console.log('========================================================='); console.log(` ${j.product} (${j.category})`); console.log('========================================================='); // --- XHS 诊断 --- console.log('\n📕 小红书:'); for (const kw of Object.keys(j.xiaohongshu?.by_keyword || {})) { const d = j.xiaohongshu.by_keyword[kw]; const nNotes = d.notes?.length || 0; const nCommentNotes = Object.keys(d.comments || {}).length; const totalComments = Object.values(d.comments || {}).reduce((s, arr) => s + (arr?.length || 0), 0); const nUsers = Object.keys(d.users || {}).length; console.log(` "${kw}": ${nNotes} 笔记, ${nCommentNotes} 笔记抓了评论 (合计 ${totalComments} 条), ${nUsers} 作者`); const tops = (d.notes || []).slice(0, 3).map((n) => `[${n.liked_count || 0}👍 ${n.comments_count || 0}💬] ${n.title?.slice(0, 50)}`); tops.forEach((t) => console.log(` • ${t}`)); } // --- 抖音诊断 --- console.log('\n🎬 抖音:'); for (const kw of Object.keys(j.douyin?.by_keyword || {})) { const d = j.douyin.by_keyword[kw]; console.log(` "${kw}": videos=${d.videos?.length || 0}, comments_groups=${Object.keys(d.comments || {}).length}`); if (d._error) console.log(` ❌ error: ${JSON.stringify(d._error).slice(0, 200)}`); if (d.videos?.length === 0) { // Dump a sample key of what we actually got console.log(` raw keys: ${Object.keys(d).join(', ')}`); } } // --- Sorftime 诊断 --- console.log('\n🌎 Sorftime:'); for (const kw of Object.keys(j.sorftime?.by_keyword || {})) { const d = j.sorftime.by_keyword[kw]; console.log(` "${kw}":`); console.log(` keyword_info keys: ${Object.keys(d.keyword_info || {}).join(', ').slice(0, 200) || '(empty)'}`); // top_products typical shape: {Data:{Items:[...]}} or {Items:[...]} const prods = d.top_products?.Data?.Items || d.top_products?.Items || d.top_products || []; console.log(` top_products 类型: ${Array.isArray(prods) ? 'Array(' + prods.length + ')' : typeof prods}`); if (Array.isArray(prods)) { prods.slice(0, 3).forEach((p) => { console.log(` • ${p.Brand || '?'} — $${(p.Price / 100).toFixed(2)} — Rank ${p.Rank} — ${(p.Title || '').slice(0, 60)}`); }); } else if (prods && typeof prods === 'object') { console.log(` top_products keys: ${Object.keys(prods).join(', ')}`); } } }