Lazada:确认选类目弹窗与 SHEIN 同套(搜索分类名称+categories-item 树);记录验证脚本自身语法错误未跑出结果

This commit is contained in:
admin9webs committed 2026-09-20 23:40:46 +08:00
1 parent 9d50eff469
commit 5b5715d95a
2 files changed
+56

No files matched your search

+17
View File
@@ -43,3 +43,20 @@
下一轮第一步:点开 `选择分类`,dump 弹窗 DOM(搜 `搜索分类名称` 输入框在不在、
结果项的 class 是什么),再决定是复用还是另写一个 `selectCategoryLazada`。
3. 因为类目一直没选上,`lazada*` store 始终为空 —— store 懒加载的结论仍未验证。
## 第 9 轮:Lazada 选类目弹窗 = 同一套「选择类目」(只差结果项这一环)
点开 `选择分类` 后 dump 到:
- 弹窗标题 **选择类目**,有 **`搜索`** 按钮和 `input[placeholder="搜索分类名称"]`
- 左侧树用 `.categories-item` / `.categories-item-name`(顶层 46 项,英文类目名)
- 右侧 **未选择分类**
- 有 `.ant-modal-close`
**结论:这就是 SHEIN/Temu/aliChoice 那套弹窗**,`selectCategory` 理论上可直接复用;
上一轮 `no-path` 的原因**尚未确认**(候选:搜索按钮没点中、结果项不是 `.search-result-item`、
或该弹窗的搜索需要先选站点维度)。下一轮只需:输入关键词 → 点搜索 → dump 弹窗内 class 频次
(`.search-result-item` 在不在)→ 在不在就补一个 `.categories-item` 分支。
⚠️ 我这一轮拼验证脚本时把模板字符串切坏了(页面里报 `SyntaxError: Unexpected token 'return'`),
没跑出结果——**这是我的脚本错误,不是平台问题**。下一轮直接在这个 `lz_cat.mjs` 上小改即可
(它已经能稳定走到「打开弹窗」),别从零写。
+39
View File
@@ -0,0 +1,39 @@
import { newPage, closePage, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
import { SAN as S } from '/tmp/cdp3.mjs';
const c = await newPage('https://www.dianxiaomi.com/web/lazada/add');
await wait(12000);
// 选店铺
const p = JSON.parse(String(await c.evalJS(`(()=>{const f=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null).find(e=>/店铺/.test((e.querySelector('label')||{}).innerText||''));
const s=f.querySelector('.ant-select-selector'); s.scrollIntoView({block:'center'}); const r=s.getBoundingClientRect();
return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`)));
await c.send('Input.dispatchMouseEvent',{type:'mouseMoved',x:p[0],y:p[1],buttons:0}); await wait(300);
for(const t of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type:t,x:p[0],y:p[1],button:'left',clickCount:1,buttons:1});
await wait(2500);
await c.evalJS(`(()=>{const dd=[...document.querySelectorAll('.ant-select-dropdown')].filter(e=>e.offsetParent!==null).pop();
const op=[...dd.querySelectorAll('.ant-select-item-option')][0]; const r=op.getBoundingClientRect();
for(const ev of ['mousedown','mouseup','click']) op.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window,clientX:r.x+r.width/2,clientY:r.y+r.height/2})); return 1;})()`);
await wait(7000);
// 点「选择分类」
console.log('打开:', String(await c.evalJS(`(()=>{const it=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null).find(e=>{
const t=(e.querySelector('label')||{}).innerText||''; return /分类/.test(t)&&!/店小秘/.test(t)&&!/选择分类/.test('')&&/选择分类/.test(e.innerText||'');});
if(!it) return 'no-item';
const b=[...it.querySelectorAll('*')].find(e=>(e.innerText||'').trim()==='选择分类'&&e.children.length===0);
if(!b) return 'no-btn';
for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 'opened';})()`)));
await wait(4000);
const d = await c.evalJS(`(()=>{
const out={};
const mods=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null);
out.modalCount=mods.length;
if(mods.length){ const m=mods[mods.length-1];
out.cls=String(m.className).slice(0,60);
out.txt=(m.innerText||'').replace(/\\s+/g,' ').trim().slice(0,220);
out.inputs=[...m.querySelectorAll('input')].map(i=>i.placeholder||i.className.slice(0,20)).slice(0,5);
const cls={}; m.querySelectorAll('*').forEach(e=>{const k=String(e.className||''); if(k&&k.length<44) cls[k]=(cls[k]||0)+1;});
out.topClasses=Object.entries(cls).sort((a,b)=>b[1]-a[1]).slice(0,12);
}
out.drops=[...document.querySelectorAll('.ant-select-dropdown,.ant-cascader-menus')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,120));
return JSON.stringify(out);})()`);
console.log('弹窗:', S(String(d)).slice(0,1400));
try{ await c.shot('/tmp/lz_cat.jpg'); console.log('shot ok'); }catch(e){}
await closePage(c); process.exit(0);