SHEIN 40/40 + Temu 全托管 46/46 批量进待发布;补 shbatch/tmbatch 配方、类目弹窗必须关、SHEIN 规格上限3、必填属性兜底、EAN 游标落盘
This commit is contained in:
1 parent
cdde45ed9a
commit
fd4cc6619b
16 files changed
+1260
-41
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { newPage, closePage, wait, installHook, readHook } from './sh_lib.mjs';
|
||||
import { selectShop, selectCategory, fillTitle, addSpecs, pickSpecValues, fillSkuRows, fillSizeTable, fillImages } from './sh_build.mjs';
|
||||
import { SAN as S } from '/tmp/cdp3.mjs';
|
||||
import { readFileSync } from 'fs';
|
||||
const P = `document.querySelector('#app').__vue_app__.config.globalProperties.$pinia`;
|
||||
const pid='694637537727', kw='保温午餐包', shop=process.env.SHOP_OVERRIDE||'②Shein-易世通达-箱包';
|
||||
const it=JSON.parse(readFileSync('/home/admin9webs/tiktok建品/tk_input.json','utf8'))[pid];
|
||||
const c=await newPage('https://www.dianxiaomi.com/web/sheinProduct/add');
|
||||
await wait(11000); await installHook(c);
|
||||
console.log('shop:', await selectShop(c, shop));
|
||||
console.log('cat:', await selectCategory(c, kw));
|
||||
await fillTitle(c, it.title); await wait(1500);
|
||||
console.log('specs:', await addSpecs(c));
|
||||
console.log('vals:', await pickSpecValues(c));
|
||||
await fillSkuRows(c,{prefix:'SHEIN',price:String(it.price_cny),supply:String(it.cost)}); await wait(2500);
|
||||
console.log('size:', await fillSizeTable(c));
|
||||
console.log('imgs:', await fillImages(c,(it.imgs||[]).slice(0,6)));
|
||||
await wait(2000);
|
||||
// 保存一次并抓全部证据
|
||||
await c.evalJS(`window.scrollTo(0,0)`); await wait(500);
|
||||
await c.evalJS(`(()=>{const x=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null).find(e=>/^\\s*保存\\s*$/.test((e.innerText||'').trim()));
|
||||
if(x) for(const ev of ['mousedown','mouseup','click']) x.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`);
|
||||
await wait(12000);
|
||||
const d = await c.evalJS(`(()=>{
|
||||
const errItems=[...document.querySelectorAll('.ant-form-item-has-error')].map(x=>{const l=x.querySelector('label'); return (l?(l.innerText||''):'?').replace(/\\s+/g,' ').trim().slice(0,40);});
|
||||
const ex=[...document.querySelectorAll('.ant-form-item-explain-error')].map(e=>(e.innerText||'').trim());
|
||||
const reds=[]; document.querySelectorAll('*').forEach(el=>{ if(el.offsetParent===null||el.children.length)return;
|
||||
const t=(el.innerText||'').trim(); if(!t||t.length>50)return; const s=getComputedStyle(el).color||'';
|
||||
const m=s.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/); if(m&&+m[1]>150&&+m[2]<130&&+m[3]<130) reds.push(t); });
|
||||
const emptyReq=[...document.querySelectorAll('.ant-form-item')].filter(e=>{
|
||||
const l=e.querySelector('label'); if(!l||!/ant-form-item-required/.test(String(l.className))) return false;
|
||||
const inp=e.querySelector('input,textarea'); if(!inp) return false;
|
||||
return !inp.value && inp.offsetParent!==null;}).map(e=>(e.querySelector('label').innerText||'').replace(/\\s+/g,' ').trim().slice(0,34));
|
||||
return JSON.stringify({errItems:[...new Set(errItems)], ex:[...new Set(ex)].slice(0,8), reds:[...new Set(reds)].slice(0,12), emptyReq:[...new Set(emptyReq)].slice(0,12)});})()`);
|
||||
console.log('诊断:', S(String(d)).slice(0,1600));
|
||||
console.log('hook:', String(await readHook(c)).slice(-300));
|
||||
try{ await c.shot('/tmp/shein_diag.jpg'); console.log('shot ok'); }catch(e){}
|
||||
await closePage(c); process.exit(0);
|
||||
Reference in new issue
Block a user