妙手:修正误判——提交一直有触发,失败因验证码读错(实测命中率约1/5);建议配 OCR 或人工登录
This commit is contained in:
1 parent
61daff1241
commit
3f60416e9c
3 files changed
+71
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { listPages, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||
import { CDP, SAN as S } from '/tmp/cdp3.mjs';
|
||||
import { readFileSync } from 'fs';
|
||||
const doc=readFileSync('/home/admin9webs/agent-a2-import/skills/ecommerce/miaoshou-erp/SKILL.md','utf8');
|
||||
const acc=(doc.match(/xiaochaoren\d+/)||[])[0], pwd=(doc.match(/Bingo\d+@/)||[])[0];
|
||||
const CAP=process.argv[2];
|
||||
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(800);
|
||||
// 1) 填表
|
||||
console.log('填表:', S(String(await c.evalJS(`(()=>{const set=(sel,v)=>{const el=document.querySelector(sel); if(!el) return 0;
|
||||
const s=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,'value').set; s.call(el,v);
|
||||
el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true})); return 1;};
|
||||
const r={a:set('input.login-form__input[placeholder="手机号/子账号/邮箱"]', ${JSON.stringify(acc)}),
|
||||
p:set('input.login-form__input[type=password]', ${JSON.stringify(pwd)}), k:set('.captcha-field__input', ${JSON.stringify(CAP)})};
|
||||
const b=document.querySelector('.login-form__submit-btn');
|
||||
if(b){const rr=b.getBoundingClientRect(); r.btn=[Math.round(rr.x+rr.width/2),Math.round(rr.y+rr.height/2)];}
|
||||
return JSON.stringify(r);})()`))).slice(0,180));
|
||||
// 2) 取按钮坐标 → 真实鼠标点击
|
||||
const pos=JSON.parse(String(await c.evalJS(`(()=>{const b=document.querySelector('.login-form__submit-btn'); if(!b) return '[]';
|
||||
const r=b.getBoundingClientRect(); return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`)));
|
||||
console.log('按钮坐标:', JSON.stringify(pos));
|
||||
await c.send('Input.dispatchMouseEvent',{type:'mouseMoved',x:pos[0],y:pos[1],buttons:0}); await wait(300);
|
||||
for(const tp of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type:tp,x:pos[0],y:pos[1],button:'left',clickCount:1,buttons:1});
|
||||
await wait(12000);
|
||||
console.log('登录:', S(String(await c.evalJS(`JSON.stringify({href:location.href, login:!!document.querySelector('input[type=password]'), err:[...document.querySelectorAll('*')].filter(e=>e.children.length===0&&/不正确|错误|锁定/.test(e.innerText||'')).map(e=>e.innerText.trim()).slice(0,2)})`))).slice(0,220));
|
||||
process.exit(0);
|
||||
Reference in new issue
Block a user