妙手:会话易失(关标签=登出)+ 登录表单位于弹窗、需先点登录再填;「导入产品」触发点本轮未测到
This commit is contained in:
1 parent
7106a41b5e
commit
834c00df2e
8 files changed
+171
-13
No files matched your search
@@ -219,3 +219,16 @@ await c.send('DOM.setFileInputFiles', { files: ['/path/ms_import.csv'], nodeId }
|
||||
### 下一步(明确到一次点击)
|
||||
进 `/common_collect_box/items` → 点 **`导入产品`** → 看它是否列出 `ms2`(或那 47 条)→
|
||||
选择并确认 → 回到列表看是否出现 47 条 → 然后才是 `认领到` → 发布权限验证。
|
||||
|
||||
## 注意:妙手会话易失 + 登录表单在弹窗里(第 5 轮踩到)
|
||||
- 关掉妙手标签后,新开标签访问受保护页会被重定向到
|
||||
`https://erp.91miaoshou.com/?redirect=%2Fcommon_collect_box%2Fitems` —— **等于登出**,需重新登录。
|
||||
- 登录表单**在一个弹窗里**:先点首页的「登录」把弹窗打开,
|
||||
再填 `.login-form__input`(账号/密码)与 `.captcha-field__input`,最后点 `.login-form__submit-btn`。
|
||||
**顺序错了会拿到 `Cannot read properties of null`**(选择器全空)——本轮我就是这么失败一次。
|
||||
- 验证码每次都要重新读(旧码会失效):取 `.captcha-field__img` 的 base64 → 存 `.jpg` → 读图。
|
||||
- **建议**:需要连续操作妙手时,别关那个标签页;中途关闭会白付一次登录(含验证码)。
|
||||
|
||||
### 「导入产品」按钮:本轮没测到
|
||||
点它之前会话就掉了(登录也未成功),所以**触发点仍未验证**。
|
||||
恢复顺序:重新登录 → `/common_collect_box/items` → 点 `导入产品` → 看是否列出 `ms2` → 确认后回列表数 47 条。
|
||||
@@ -0,0 +1,20 @@
|
||||
import { listPages, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||
import { CDP } from '/tmp/cdp3.mjs';
|
||||
import { writeFileSync } from 'fs';
|
||||
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');
|
||||
if (!String(await c.evalJS('location.href')).includes('91miaoshou.com/?redirect') && !String(await c.evalJS('!!document.querySelector(".captcha-field__img")'))) {
|
||||
await c.send('Page.navigate',{url:'https://erp.91miaoshou.com/'}); await wait(10000);
|
||||
}
|
||||
// 确保登录弹窗/表单可见
|
||||
await c.evalJS(`(()=>{const b=[...document.querySelectorAll('button,a')].find(e=>/^\\s*登录\\s*$/.test((e.innerText||'').trim())); if(b) b.click(); return 1;})()`);
|
||||
await wait(2500);
|
||||
const src = String(await c.evalJS(`(()=>{const i=document.querySelector('.captcha-field__img'); return i?(i.src||''):'';})()`));
|
||||
const b64 = src.includes('base64,') ? src.split('base64,')[1] : '';
|
||||
if(!b64){ console.log('没找到验证码图'); process.exit(1); }
|
||||
writeFileSync('/tmp/ms_cap3.jpg', Buffer.from(b64,'base64'));
|
||||
console.log('验证码已存 /tmp/ms_cap3.jpg');
|
||||
const f = await c.evalJS(`JSON.stringify({acc:!!document.querySelector('input.login-form__input[placeholder="手机号/子账号/邮箱"]'), pwd:!!document.querySelector('input.login-form__input[type=password]'), btn:!!document.querySelector('.login-form__submit-btn')})`);
|
||||
console.log('表单:', String(f));
|
||||
process.exit(0);
|
||||
@@ -0,0 +1,27 @@
|
||||
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 c.send('Page.navigate',{url:'https://erp.91miaoshou.com/common_collect_box/items'});
|
||||
await wait(12000);
|
||||
const pos = JSON.parse(String(await c.evalJS(`(()=>{
|
||||
const bs=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null&&(e.innerText||'').trim()==='导入产品');
|
||||
if(!bs.length) return '[]'; const b=bs[0]; b.scrollIntoView({block:'center'});
|
||||
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));
|
||||
if(pos.length){
|
||||
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(6000);
|
||||
const o = await c.evalJS(`(()=>{
|
||||
const dlgs=[...document.querySelectorAll('.jx-dialog,.jx-drawer,[class*=dialog]')].filter(e=>e.offsetParent!==null)
|
||||
.map(e=>({txt:(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,300),
|
||||
btns:[...e.querySelectorAll('button')].map(b=>(b.innerText||'').trim()).filter(Boolean).slice(0,8),
|
||||
files:[...e.querySelectorAll('input[type=file]')].length}));
|
||||
const rows=[...document.querySelectorAll('tr')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim()).filter(Boolean).slice(0,4);
|
||||
return JSON.stringify({href:location.href, dlgs:dlgs.slice(0,2), rows});})()`);
|
||||
console.log('结果:', S(String(o)).slice(0,1100));
|
||||
try{ await c.shot('/tmp/ms_importprod.jpg'); console.log('shot ok'); }catch(e){}
|
||||
process.exit(0);
|
||||
@@ -0,0 +1,39 @@
|
||||
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(1200);
|
||||
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 a=document.querySelector('input.login-form__input[placeholder="手机号/子账号/邮箱"]');
|
||||
const p=document.querySelector('input.login-form__input[type=password]');
|
||||
const k=document.querySelector('.captcha-field__input');
|
||||
return JSON.stringify({a:set(a, ${JSON.stringify(acc)}), p:set(p, ${JSON.stringify(pwd)}), k:set(k, ${JSON.stringify(CAP)})});})()`);
|
||||
await wait(700);
|
||||
await c.evalJS(`(()=>{const b=document.querySelector('.login-form__submit-btn'); if(b) for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`);
|
||||
await wait(12000);
|
||||
const st=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)})`);
|
||||
console.log('登录:', S(String(st)).slice(0,220));
|
||||
// 进采集箱点「导入产品」
|
||||
await c.send('Page.navigate',{url:'https://erp.91miaoshou.com/common_collect_box/items'}); await wait(13000);
|
||||
const pos=JSON.parse(String(await c.evalJS(`(()=>{const b=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null&&(e.innerText||'').trim()==='导入产品');
|
||||
if(!b.length) return '[]'; b[0].scrollIntoView({block:'center'}); const r=b[0].getBoundingClientRect();
|
||||
return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`)));
|
||||
console.log('导入产品坐标:', JSON.stringify(pos));
|
||||
if(pos.length){
|
||||
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(6000);
|
||||
}
|
||||
const o=await c.evalJS(`(()=>{const dlgs=[...document.querySelectorAll('.jx-dialog,.jx-drawer,[class*=dialog]')].filter(e=>e.offsetParent!==null)
|
||||
.map(e=>({txt:(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,260), btns:[...e.querySelectorAll('button')].map(b=>(b.innerText||'').trim()).filter(Boolean).slice(0,6)}));
|
||||
const body=(document.body.innerText||'').replace(/\\s+/g,' ');
|
||||
return JSON.stringify({dlgs:dlgs.slice(0,2), empty:/暂无数据/.test(body), body:body.slice(0,160)});})()`);
|
||||
console.log('导入产品结果:', S(String(o)).slice(0,1000));
|
||||
try{ await c.shot('/tmp/ms_ip.jpg'); console.log('shot ok'); }catch(e){}
|
||||
process.exit(0);
|
||||
@@ -0,0 +1,33 @@
|
||||
import { newPage, listPages, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||
import { CDP, SAN as S } from '/tmp/cdp3.mjs';
|
||||
let t = (await listPages()).find(x=>/91miaoshou/i.test(x.url));
|
||||
let c;
|
||||
if (t) { c = await CDP.connect(t.webSocketDebuggerUrl); await c.send('Page.enable'); await c.send('Runtime.enable'); }
|
||||
else {
|
||||
console.log('无妙手标签,新开…');
|
||||
c = await newPage('https://erp.91miaoshou.com/common_collect_box/items');
|
||||
await wait(14000);
|
||||
}
|
||||
await c.send('Page.navigate',{url:'https://erp.91miaoshou.com/common_collect_box/items'});
|
||||
await wait(13000);
|
||||
const st = await c.evalJS(`JSON.stringify({href:location.href, login:!!document.querySelector('input[type=password]'), title:document.title})`);
|
||||
console.log('页面:', S(String(st)).slice(0,200));
|
||||
const pos = JSON.parse(String(await c.evalJS(`(()=>{
|
||||
const bs=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null&&(e.innerText||'').trim()==='导入产品');
|
||||
if(!bs.length) return '[]'; const b=bs[0]; b.scrollIntoView({block:'center'});
|
||||
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));
|
||||
if(pos.length){
|
||||
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(6000);
|
||||
}
|
||||
const o = await c.evalJS(`(()=>{
|
||||
const dlgs=[...document.querySelectorAll('.jx-dialog,.jx-drawer,[class*=dialog]')].filter(e=>e.offsetParent!==null)
|
||||
.map(e=>({txt:(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,260), btns:[...e.querySelectorAll('button')].map(b=>(b.innerText||'').trim()).filter(Boolean).slice(0,6), files:[...e.querySelectorAll('input[type=file]')].length}));
|
||||
const rows=[...document.querySelectorAll('tr')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim()).filter(Boolean).slice(0,4);
|
||||
const body=(document.body.innerText||'').replace(/\\s+/g,' ');
|
||||
return JSON.stringify({dlgs:dlgs.slice(0,2), rows, empty:/暂无数据/.test(body)});})()`);
|
||||
console.log('结果:', S(String(o)).slice(0,1200));
|
||||
try{ await c.shot('/tmp/ms_importprod.jpg'); console.log('shot ok'); }catch(e){}
|
||||
process.exit(0);
|
||||
Reference in new issue
Block a user