Lazada 英文类目词实测表(8 词 5 中)+ README 第19条坑:搜不到≠结构不同,先怀疑输入
This commit is contained in:
1 parent
830db017a3
commit
b127e5c552
3 files changed
+92
-1
No files matched your search
@@ -76,7 +76,7 @@ function wrap(o, n, l) {
|
||||
批量脚本请用 `shein建品/sh_lib.mjs` 的 `newPage(url)`:按 target 直连,不会抢错
|
||||
- VNC:`http://192.168.9.122:6097/vnc.html` 或 `:6100`(免密)
|
||||
|
||||
## 十八条会重复踩的坑
|
||||
## 十九条会重复踩的坑
|
||||
|
||||
1. **保存静默拦截** → 挂钩子,别猜
|
||||
2. **`idStr ≠ id`** → 大整数精度丢失,服务端操作一律用 `idStr`
|
||||
@@ -103,6 +103,10 @@ function wrap(o, n, l) {
|
||||
否则只能拿到列表第一项(Joom 详情图语言会落到「阿拉伯语」)
|
||||
18. **找不到字段落点?打一个哨兵串** → 在页面手输 `PROBE-TITLE-XYZ`,再遍历所有 pinia store
|
||||
的 `$state` 找这个串,立刻知道数据落在哪个 store(Joom 就是这么发现数据在 `smtChoice*` 的)
|
||||
|
||||
19. **搜不到 ≠ 结构不同:先怀疑输入,再怀疑结构** → Lazada 的类目树是**英文**的,
|
||||
拿中文「发圈」去搜,搜索确实执行了但结果 0 条;换成 `Hair Accessories` 立刻出 6 条、
|
||||
结构还与 SHEIN 完全一致。我们为此多花了 2 轮去怀疑「弹窗结构不同」
|
||||
(Temu 第一轮就撞了一次,靠编辑页改号救回来)
|
||||
|
||||
## EAN-13 台账(湖北易千亿彩 · 69803093 段)
|
||||
|
||||
@@ -107,3 +107,23 @@ sr[2] Kids' Fashion(童装)/Baby & Kids' Accessories(…)/…
|
||||
2. 或直接从英文 `title` 抽名词短语(`Hair Ties` / `Whistle` / `Pencil Case` / `Lunch Bag`);
|
||||
3. 拿到英文词后,**直接抄 `alichoice建品/alcbatch.mjs` 的骨架**(选店 → selectCategory → 填 store → 挂钩子保存),
|
||||
差异只在于:Lazada 必填含**品牌**(要真实品牌或「无品牌」占位)和**税**。
|
||||
|
||||
## 第 11 轮:英文类目词实测表(`lz_kwtest.mjs`,一次会话连测 8 词)
|
||||
|
||||
| 我们的中文 `cat_kw` | 试的英文词 | `.search-result-item` 命中 | 首个结果路径(截断) |
|
||||
|---|---|---|---|
|
||||
| 发圈/发饰 | `Hair Accessories` | **6** ✅ | Beauty/Personal Care/Hair Care/…/Hair Accessories |
|
||||
| 笔袋 | `Pencil Case` | **1** ✅ | Stationery, Craft & Gift Cards/School & Office/… |
|
||||
| 保温午餐包 | `Lunch Bag` | **3** ✅ | Bags and Travel/Functional Bags/Lunch Bags |
|
||||
| 涂鸦贴纸 | `Stickers` | **5** ✅ | Automotive/…/Bumper Stickers, Decals & Ma… |
|
||||
| 袜子 | `Socks` | **6** ✅ | Kids' Fashion/Baby Clothing/…/Socks & Tight… |
|
||||
| 口哨 | `Whistle` | 0 ❌ | 换词:`Toy Whistle` / `Party Favors` / `Whistles` |
|
||||
| 钥匙扣 | `Keychain` | 0 ❌ | 换词:`Key Ring` / `Key Chain` / `Keychains` |
|
||||
| 纽扣 | `Buttons` | 0 ❌ | 换词:`Sewing Buttons` / `Button` |
|
||||
|
||||
**用法**:`cat_kw → 英文词` 先查这张表,未命中的按上面「换词」列逐个试(一个词 25 秒);
|
||||
命中后 `selectCategory(c, 英文词, 英文词)` 可直接用(结果项同构,见上一节)。
|
||||
|
||||
**注意**:命中 ≠ 落对类目。例如 `Stickers` 首个结果是汽车保险杠贴纸,
|
||||
而我们要的是「涂鸦贴纸」——所以**结果项要按最后一级精确匹配**(`selectCategory` 第三参已支持),
|
||||
必要时人工核一遍 `lazada_route.json`。
|
||||
@@ -0,0 +1,67 @@
|
||||
/** Lazada 英文类目词实测:一次会话里连续测多个关键词,输出各自命中数 */
|
||||
import { newPage, closePage, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||
import { SAN as S } from '/tmp/cdp3.mjs';
|
||||
|
||||
const KWS = ['Hair Accessories', 'Whistle', 'Pencil Case', 'Lunch Bag', 'Stickers', 'Keychain', 'Buttons', 'Socks'];
|
||||
|
||||
const c = await newPage('https://www.dianxiaomi.com/web/lazada/add');
|
||||
await wait(12000);
|
||||
// 选店铺
|
||||
const pos = 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?f.querySelector('.ant-select-selector'):null; if(!s) return '[]';
|
||||
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: pos[0], y: pos[1], buttons: 0 }); await wait(300);
|
||||
for (const t of ['mousePressed', 'mouseReleased'])
|
||||
await c.send('Input.dispatchMouseEvent', { type: t, x: pos[0], y: pos[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);
|
||||
|
||||
async function openModal() {
|
||||
return 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(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';})()`);
|
||||
}
|
||||
async function closeModal() {
|
||||
await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop();
|
||||
if(!m) return 0; const b=[...m.querySelectorAll('button')].find(x=>/^\\s*关闭\\s*$/.test((x.innerText||'').trim()))
|
||||
||m.querySelector('.ant-modal-close');
|
||||
if(b) for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window}));
|
||||
return 1;})()`);
|
||||
await wait(1500);
|
||||
await c.send('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 }).catch(() => {});
|
||||
await wait(1200);
|
||||
}
|
||||
|
||||
for (const kw of KWS) {
|
||||
await openModal();
|
||||
await wait(2500);
|
||||
await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop();
|
||||
if(!m) return 0; const inp=m.querySelector('input[placeholder="搜索分类名称"]')||m.querySelector('input'); if(!inp) return 0;
|
||||
const setter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,'value').set;
|
||||
setter.call(inp, ${JSON.stringify(kw)}); inp.dispatchEvent(new Event('input',{bubbles:true})); return 1;})()`);
|
||||
await wait(700);
|
||||
await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop();
|
||||
if(!m) return 0; const b=[...m.querySelectorAll('button')].find(x=>/^\\s*搜索\\s*$/.test((x.innerText||'').trim()));
|
||||
if(b) for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`);
|
||||
await wait(4000);
|
||||
const r = await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop();
|
||||
if(!m) return JSON.stringify({n:0});
|
||||
const sr=[...m.querySelectorAll('.search-result-item')];
|
||||
const first=sr[0]?(sr[0].innerText||'').replace(/\\s+/g,' ').trim().slice(0,80):'';
|
||||
return JSON.stringify({n:sr.length, first});})()`);
|
||||
console.log('KW', JSON.stringify(kw), '→', S(String(r)).slice(0, 130));
|
||||
await closeModal();
|
||||
}
|
||||
await closePage(c);
|
||||
process.exit(0);
|
||||
Reference in new issue
Block a user