aliChoice:类目 dry 扫描(47/47 避开强制说明书类目)+ 批量读 alc_route.json;记录 SKU分类/材质/尺寸 两类新失败

This commit is contained in:
admin9webs committed 2026-09-20 22:46:02 +08:00
1 parent a5c32e4726
commit de9d988f4c
5 files changed
+351 -10

No files matched your search

+12 -9
View File
@@ -24,6 +24,7 @@ const only = argv.filter(a => !a.startsWith('--'));
let tasks = Object.keys(INPUT).filter(pid => (INPUT[pid].imgs || []).length > 0).map(pid => ({ pid }));
if (only.length) tasks = tasks.filter(t => only.includes(t.pid)); else tasks = tasks.filter(t => !SKIP.has(t.pid));
let done = {}; try { done = JSON.parse(readFileSync(DONE_F, 'utf8')); } catch {}
let ROUTE = {}; try { ROUTE = JSON.parse(readFileSync(`${DIR}/alc_route.json`, 'utf8')); } catch {}
const log = m => { const l = `[${new Date().toISOString().slice(11, 19)}] ${m}`; console.log(l); appendFileSync(LOG_F, l + '\n'); };
/** PC端描述:真实控件是 CKEditor(隐藏 textarea + 所见即所得),给编辑器实例 setData 才有效 */
@@ -109,15 +110,17 @@ for (const t of tasks) {
await wait(6000);
log(` 备货类型: ${await pickFirstOption(c, '备货类型')}`);
await wait(3000);
// 类目:cat_kw 搜不到就依次试 cat_fb(tk_input 里给的后备品类词)
let cat = await selectCategory(c, it.cat_kw || '发夹', it.cat_kw);
if (!String(cat).startsWith('path:')) {
for (const fb of (it.cat_fb || []).slice(0, 3)) {
cat = await selectCategory(c, fb, fb);
if (String(cat).startsWith('path:')) { log(` 类目回退到「${fb}」`); break; }
}
// 类目:用 alcdry.mjs 扫出来的词(已确认该词落到的类目不强制「商品说明书」)
const rc = ROUTE[t.pid];
if (!rc || !rc.cat) {
log(` ⏭ 跳过:没有不要求资质文件的类目(dry 扫描结论)`);
done[t.pid] = { ok: false, skipped: true, msg: '无可用类目:全部候选都强制商品说明书' };
await closePage(c); c = null;
if (!dry) writeFileSync(DONE_F, JSON.stringify(done, null, 1));
continue;
}
log(` 类目: ${String(cat).slice(0, 110)}`);
const cat = await selectCategory(c, rc.cat, rc.cat);
log(` 类目: 「${rc.cat}」 ${String(cat).slice(0, 90)}`);
if (!String(cat).startsWith('path:')) throw new Error('选类目失败:' + cat);
await wait(6000);
const fill = await c.evalJS(`(()=>{const p=${P}; const imgs=${JSON.stringify((it.imgs || []).slice(0, 6))};
@@ -156,7 +159,7 @@ for (const t of tasks) {
const red=[...x.querySelectorAll('.text-red-500')].map(e=>(e.innerText||'').trim().slice(0,30)).filter(Boolean);
return t+':'+red.join('/');}).slice(0,6))`));
const ok = /已保存|保存成功|待发布/.test(mods);
done[t.pid] = ok ? { ok: true } : { ok: false, errItems: errItems.slice(0, 260), mods: mods.slice(0, 120), hook: String(cap).slice(-200) };
done[t.pid] = ok ? { ok: true, cat: rc.cat, path: rc.path } : { ok: false, cat: rc.cat, errItems: errItems.slice(0, 260), mods: mods.slice(0, 120), hook: String(cap).slice(-200) };
log(ok ? ' ✓ 已保存到待发布' : ` ✗ 失败 ${mods.slice(0, 110)} | ${String(cap).slice(-170)}`);
} catch (e) {
done[t.pid] = { ok: false, msg: String(e).slice(0, 240) };