v10.12 修复hr1打招呼失败: 开弹窗改Playwright原生点击(合成click被平台反自动化检测拦截返回空壳弹窗); 新增空壳弹窗识别+重试+跳过逻辑
This commit is contained in:
@@ -447,15 +447,39 @@ async function scrapeZhaopin(maxCount = 20, fullMode = false, scoreOnly = false)
|
||||
if (cardBlackHit) { log(`🚫 [跳过-列表黑名单] ${card.name} | 卡片含"${cardBlackHit}"`); skipped++; currentDataIndex = await navigateToNextCard(page, currentDataIndex); continue; }
|
||||
|
||||
try {
|
||||
// 打开弹窗
|
||||
await page.evaluate((di) => {
|
||||
const el = document.querySelector(`.recommend-item[data-index="${di}"] .resume-item__content`);
|
||||
(el || document.querySelector(`.recommend-item[data-index="${di}"]`))?.click();
|
||||
}, currentDataIndex);
|
||||
// 打开弹窗(v10.12:Playwright原生点击替代evaluate合成click——平台反自动化检测会
|
||||
// 对合成点击返回空白弹窗;原生点击走真实鼠标事件流 CDP Input.dispatchMouseEvent)
|
||||
try {
|
||||
const cardLoc = page.locator(`.recommend-item[data-index="${currentDataIndex}"] .resume-item__content`).first();
|
||||
await cardLoc.click({ timeout: 8000 });
|
||||
} catch (_) {
|
||||
// 兜底:内容区选择器失败时点卡片本身(同样用原生点击)
|
||||
await page.locator(`.recommend-item[data-index="${currentDataIndex}"]`).first().click({ timeout: 8000 });
|
||||
}
|
||||
await randomSleep(3, 5);
|
||||
if (!await page.evaluate(() => !!document.querySelector('.km-modal--open') || !!document.querySelector('.km-modal__backdrop--active'))) {
|
||||
// 弹窗有效性双检:不仅看"有弹窗",还要看是简历弹窗(空壳km-modal说明被拦截)
|
||||
const modalOk = await page.evaluate(() => ({
|
||||
open: !!document.querySelector('.km-modal--open, .km-modal__backdrop--active'),
|
||||
isResume: !!document.querySelector('.new-shortcut-resume__modal'),
|
||||
}));
|
||||
if (!modalOk.open) {
|
||||
log('弹窗未打开,跳过'); errors++; currentDataIndex = await navigateToNextCard(page, currentDataIndex); continue;
|
||||
}
|
||||
if (!modalOk.isResume) {
|
||||
// 空壳弹窗:关掉重试一次原生点击;再不行跳过该人
|
||||
log('弹窗为空壳(非简历弹窗),关闭重试');
|
||||
await closeModal(page);
|
||||
await randomSleep(2, 3);
|
||||
try {
|
||||
await page.locator(`.recommend-item[data-index="${currentDataIndex}"] .resume-item__content`).first().click({ timeout: 8000 });
|
||||
await randomSleep(3, 5);
|
||||
} catch (_) { }
|
||||
const retryOk = await page.evaluate(() => !!document.querySelector('.new-shortcut-resume__modal'));
|
||||
if (!retryOk) {
|
||||
await closeModal(page);
|
||||
log('重试仍是空壳弹窗,跳过该卡片'); errors++; currentDataIndex = await navigateToNextCard(page, currentDataIndex); continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 平台唯一标识
|
||||
const resumeNumber = extractResumeNumber(page);
|
||||
|
||||
Reference in New Issue
Block a user