From 3f60416e9c84e445a5b5ddc06b00fac2a623513d Mon Sep 17 00:00:00 2001 From: admin9webs Date: Thu, 24 Sep 2026 23:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=99=E6=89=8B=EF=BC=9A=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=AF=AF=E5=88=A4=E2=80=94=E2=80=94=E6=8F=90=E4=BA=A4=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=9C=89=E8=A7=A6=E5=8F=91=EF=BC=8C=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=9B=A0=E9=AA=8C=E8=AF=81=E7=A0=81=E8=AF=BB=E9=94=99=EF=BC=88?= =?UTF-8?q?=E5=AE=9E=E6=B5=8B=E5=91=BD=E4=B8=AD=E7=8E=87=E7=BA=A61/5?= =?UTF-8?q?=EF=BC=89=EF=BC=9B=E5=BB=BA=E8=AE=AE=E9=85=8D=20OCR=20=E6=88=96?= =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 妙手建品/RECIPE.md | 30 ++++++++++++++++++++++++++++++ 妙手建品/ms_diag_login.mjs | 14 ++++++++++++++ 妙手建品/ms_login5.mjs | 27 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 妙手建品/ms_diag_login.mjs create mode 100644 妙手建品/ms_login5.mjs diff --git a/妙手建品/RECIPE.md b/妙手建品/RECIPE.md index 4d28bd8..9d07bae 100644 --- a/妙手建品/RECIPE.md +++ b/妙手建品/RECIPE.md @@ -248,3 +248,33 @@ await c.send('DOM.setFileInputFiles', { files: ['/path/ms_import.csv'], nodeId } 去做 `导入产品` 那个触发点的验证(`/common_collect_box/items` → `导入产品` → 看是否列出 `ms2`)。 若仍需我自动登录:下一步应改为**真实鼠标点 `.login-form__submit-btn`**(`Input.dispatchMouseEvent`), 而不是 DOM `dispatchEvent`——这是本轮与前几轮唯一的行为差异。 + +## 第 7 轮:修正上一轮的误判 —— 提交其实**是**触发的,失败原因是验证码读错 + +只读诊断(没有再次尝试登录)看到: +``` +按钮: {dis:false, txt:"立即登录"} +输入: [{ph:"手机号/子账号/邮箱", val:"xia…"}, {ph:"密码", val:"Bin…"}, {ph:"请输入验证码", val:"…"}] ← 空 +``` +**关键**:账号和密码的值**还在**,**验证码框被清空了**。 +这是典型的「提交已发出并被拒 → 前端清空验证码并刷新图片」行为。 +所以上一轮我写的「提交疑似未触发」是**错的**:提交一直有触发, +失败原因是**验证码读错**(错误提示是短暂 toast,我 12 秒后才查 DOM,已经消失)。 + +### 验证码识别的实测命中率(人眼读 base64 原图) +| 次数 | 读数 | 结果 | +|---|---|---| +| 1 | `4821` | ❌ 读错 | +| 2 | `0699` | ✅ 通过(唯一一次成功登录) | +| 3 | `7317` | ❌ | +| 4 | `0326` | ❌ | +| 5 | `3620` | ❌ | + +→ **约 1/5**。而登录页写着「再失败 9 次将锁定账号 1 个小时」,所以**不该继续靠人眼读码硬试**。 + +### 结论与建议 +- 要自动化妙手,**必须给验证码配 OCR/视觉能力**: + 本机 `modlens` 未配置视觉提供方(报 `No vision provider`); + 舰队技能里另有 `ddddocr` / `captcha-solving` 相关技能可先查。 +- 或者**人工在 VNC 登录一次**,agent 接手已登录会话(零风险、立刻可用)。 +- 登录后要立刻做的仍是那件事:`/common_collect_box/items` → 点 **`导入产品`** → 看是否列出 `ms2`。 diff --git a/妙手建品/ms_diag_login.mjs b/妙手建品/ms_diag_login.mjs new file mode 100644 index 0000000..7f1141d --- /dev/null +++ b/妙手建品/ms_diag_login.mjs @@ -0,0 +1,14 @@ +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('Runtime.enable'); await wait(1000); +const o=await c.evalJS(`(()=>{ + const b=document.querySelector('.login-form__submit-btn'); + const ins=[...document.querySelectorAll('input')].filter(e=>e.offsetParent!==null).map(e=>({ph:e.placeholder||'',val:String(e.value||'').slice(0,3)+'…',dis:e.disabled,ro:e.readOnly})); + const txt=(document.body.innerText||'').replace(/\\s+/g,' '); + const hints=txt.match(/.{0,16}(锁定|失败|次数|验证|禁用).{0,22}/g); + return JSON.stringify({btn: b?{dis:b.disabled, cls:String(b.className).slice(0,60), txt:(b.innerText||'').trim()}:null, + ins, hints:(hints||[]).slice(0,6), href:location.href});})()`); +console.log('诊断:', S(String(o)).slice(0,900)); +process.exit(0); diff --git a/妙手建品/ms_login5.mjs b/妙手建品/ms_login5.mjs new file mode 100644 index 0000000..0770b7f --- /dev/null +++ b/妙手建品/ms_login5.mjs @@ -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);