21 lines
1.5 KiB
JavaScript
21 lines
1.5 KiB
JavaScript
import { listPages, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
|
import { CDP, SAN as S } from '/tmp/cdp3.mjs';
|
|
const t = (await listPages()).find(x=>/91miaoshou/i.test(x.url));
|
|
const c = await CDP.connect(t.webSocketDebuggerUrl);
|
|
await c.send('Page.enable'); await c.send('Runtime.enable'); await wait(1200);
|
|
// 点左侧「公用采集箱」
|
|
console.log('点公用采集箱:', String(await c.evalJS(`(()=>{
|
|
const h=[...document.querySelectorAll('*')].filter(e=>e.offsetParent!==null&&(e.innerText||'').trim()==='公用采集箱'&&e.children.length===0);
|
|
if(!h.length) return 'nf';
|
|
for(const ev of ['mousedown','mouseup','click']) h[0].dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 'clicked';})()`)));
|
|
await wait(9000);
|
|
const o = await c.evalJS(`(()=>{
|
|
const body=(document.body.innerText||'').replace(/\\s+/g,' ');
|
|
const m=body.match(/共\\s*\\d+\\s*[条个]/);
|
|
const rows=[...document.querySelectorAll('tr')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim()).filter(Boolean).slice(0,4);
|
|
const btns=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null).map(e=>({t:(e.innerText||'').trim().slice(0,10), dis:e.disabled})).filter(x=>x.t).slice(0,14);
|
|
return JSON.stringify({href:location.href, total:m?m[0]:'', rows, btns});})()`);
|
|
console.log('采集箱:', S(String(o)).slice(0,1200));
|
|
try{ await c.shot('/tmp/ms_box.jpg'); console.log('shot ok'); }catch(e){}
|
|
process.exit(0);
|