From 33f67279c13923bb50d07701dffc6d0b96d66075 Mon Sep 17 00:00:00 2001 From: Oscar Date: Mon, 1 Jun 2026 13:01:42 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A0=EF=B8=8F=20fix(scraper):=20=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=B0=D0=B2=D0=BB=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B8=2010=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D1=80=D1=8F=D0=B4=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B2=D0=B0=D0=BA=D0=B0=D0=BD=D1=81?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hh/scraper.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hh/scraper.ts b/src/hh/scraper.ts index 75a2ff5..f90837f 100644 --- a/src/hh/scraper.ts +++ b/src/hh/scraper.ts @@ -334,9 +334,16 @@ export async function applyToJobs( ) let appliedCount = 0 + let consecutiveSkips = 0 + const MAX_CONSECUTIVE_SKIPS = 10 for (const vacancy of vacancies) { if (appliedCount >= maxApplies) break + if (consecutiveSkips >= MAX_CONSECUTIVE_SKIPS) { + log.warn(`Остановлено: ${MAX_CONSECUTIVE_SKIPS} пропусков подряд`) + await keep(`⚠️ Остановлено: ${MAX_CONSECUTIVE_SKIPS} вакансий подряд пропущено`) + break + } const ref: VacancyRef = { title: vacancy.title, href: vacancy.href } if (knownSkipped.has(vacancy.href)) { @@ -355,12 +362,16 @@ export async function applyToJobs( if (!description) { results.skipped.push(ref) + appliedCount++ + consecutiveSkips++ continue } const applyBtn = await page.$('[data-qa="vacancy-response-link-top"]') if (!applyBtn) { results.skipped.push(vacancy) + appliedCount++ + consecutiveSkips++ continue } @@ -372,8 +383,11 @@ export async function applyToJobs( if (relocationConfirm) await relocationConfirm.click() - if (await skipIfQuestionnaire(page, vacancy, ref, chatId, status, results)) + if (await skipIfQuestionnaire(page, vacancy, ref, chatId, status, results)) { + appliedCount++ + consecutiveSkips++ continue + } // console.log('[LetterDebug]:', '\nresume: ', resume.data, '\ndescription: ', description, '\nprompt: ', user!.prompt) await keep(`✍️ Генерирую письмо: ${vacancy.title}`) @@ -487,6 +501,7 @@ export async function applyToJobs( results.applied.push(ref) appliedCount++ + consecutiveSkips = 0 } catch (err) { results.errors.push({ ...ref, message: (err as Error).message })