From 4e4cec3e1b72a634827c20265be4139e20adc05c Mon Sep 17 00:00:00 2001 From: hermes Date: Wed, 2 Sep 2026 02:35:32 +0000 Subject: [PATCH] =?UTF-8?q?v10.10=20=E6=89=93=E6=8B=9B=E5=91=BC=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BF=AE=E5=A4=8D:=20=E5=90=88=E6=88=90click=E6=94=B9?= =?UTF-8?q?Playwright=E5=8E=9F=E7=94=9Flocator=E7=82=B9=E5=87=BB(=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=BC=B9=E7=AA=97=E4=B8=8D=E5=93=8D=E5=BA=94=E5=90=88?= =?UTF-8?q?=E6=88=90=E7=82=B9=E5=87=BB),=20=E5=9B=BA=E5=AE=9A2.5s=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=94=B98s=E8=BD=AE=E8=AF=A2+=E9=87=8D=E8=AF=951?= =?UTF-8?q?=E6=AC=A1=E2=80=94=E2=80=94=E4=BB=8A=E6=99=A8hr1=E8=BF=9E?= =?UTF-8?q?=E7=BB=AD3=E6=AC=A1=E5=A4=B1=E8=B4=A5=E7=86=94=E6=96=AD?= =?UTF-8?q?=E7=9A=84=E6=A0=B9=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/zhaopin-scrape.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/zhaopin-scrape.js b/scripts/zhaopin-scrape.js index 42ab3dc..654cabc 100755 --- a/scripts/zhaopin-scrape.js +++ b/scripts/zhaopin-scrape.js @@ -145,16 +145,25 @@ async function closeModal(page) { // 弹窗内打招呼(v9:天然绑定正确的人,杜绝列表 index 错位) async function clickGreetInModal(page) { - return page.evaluate(async () => { - const btn = document.querySelector('.new-shortcut-resume__modal button.km-button--primary.km-button--filled'); - if (!btn) return false; - const t = btn.innerText.trim(); - if (t === '继续沟通') return true; // 已打过 - if (!t.includes('打招呼')) return false; - btn.click(); - await new Promise(r => setTimeout(r, 2500)); - return btn.innerText.trim() === '继续沟通'; - }); + // v10.10(2026-09-02):原生 locator 点击(合成 click 对部分弹窗无效) + // + 轮询等待按钮变化(最长8秒,替代固定2.5秒)+ 失败重试1次 + for (let attempt = 0; attempt < 2; attempt++) { + try { + const btn = page.locator('.new-shortcut-resume__modal button.km-button--primary.km-button--filled').first(); + const t = (await btn.innerText({ timeout: 5000 }).catch(() => '')).trim(); + if (t === '继续沟通') return true; // 已打过 + if (!t.includes('打招呼')) return false; + await btn.click({ timeout: 5000 }); + // 轮询等按钮变"继续沟通"(最长8秒) + for (let i = 0; i < 16; i++) { + await new Promise(r => setTimeout(r, 500)); + const t2 = (await btn.innerText({ timeout: 2000 }).catch(() => '')).trim(); + if (t2 === '继续沟通') return true; + } + // 8秒没变——重试一次(第二次 attempt) + } catch (_) { /* 进重试 */ } + } + return false; } // 人类行为模拟:弹窗内容超一屏时随机滚动