// 直接请求 articleListStatistic,尝试不同 type 参数 import { connect, evaluate, saveJson } from './lib.mjs'; const cdp = await connect(); const { targetInfos } = await cdp.send('Target.getTargets'); const page = targetInfos.find(t => t.type === 'page' && t.url.includes('baijiahao.baidu.com')); const { sessionId } = await cdp.send('Target.attachToTarget', { targetId: page.targetId, flatten: true }); await cdp.send('Runtime.enable', {}, sessionId); const types = ['video', 'all', 'news', 'smallvideo', 'image']; const out = {}; for (const t of types) { const expr = `(async () => { const url = '/author/eco/statistics/articleListStatistic?start_day=20261010&end_day=20261109&type=${t}&num=1&count=50'; const r = await fetch(url, { credentials: 'include' }); const j = await r.json(); return { type: '${t}', errno: j.errno, count: j.data && j.data.count, len: j.data && j.data.list ? j.data.list.length : -1, sample: j.data && j.data.list ? j.data.list[0] : null }; })()`; try { out[t] = await evaluate(cdp, sessionId, expr); } catch (e) { out[t] = { error: e.message.slice(0, 200) }; } } saveJson('out/types-probe.json', out); for (const [k, v] of Object.entries(out)) { console.log(`${k}: errno=${v.errno} count=${v.count} len=${v.len} ${v.error || ''}`); } process.exit(0);