mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-08 04:25:25 +00:00
Return an error when no selectors are found, #25
This commit is contained in:
parent
37cd979bf7
commit
c3b2173f39
@ -147,9 +147,12 @@ async function resolveChallenge(ctx: RequestContext, { url, maxTimeout, proxy, d
|
|||||||
|
|
||||||
if (response.status() > 400) {
|
if (response.status() > 400) {
|
||||||
// detect cloudflare wait 5s
|
// detect cloudflare wait 5s
|
||||||
|
let selectorFoundCount = 0
|
||||||
for (const selector of CHALLENGE_SELECTORS) {
|
for (const selector of CHALLENGE_SELECTORS) {
|
||||||
const cfChallengeElem = await page.$(selector)
|
const cfChallengeElem = await page.$(selector)
|
||||||
if (cfChallengeElem) {
|
if (cfChallengeElem) {
|
||||||
|
selectorFoundCount++
|
||||||
|
log.debug(`'${selector}' challenge element detected.`)
|
||||||
log.debug('Waiting for Cloudflare challenge...')
|
log.debug('Waiting for Cloudflare challenge...')
|
||||||
|
|
||||||
let interceptingResult: ChallengeResolutionT;
|
let interceptingResult: ChallengeResolutionT;
|
||||||
@ -196,6 +199,12 @@ async function resolveChallenge(ctx: RequestContext, { url, maxTimeout, proxy, d
|
|||||||
log.debug(`No '${selector}' challenge element detected.`)
|
log.debug(`No '${selector}' challenge element detected.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.debug("Number of selector found: " + selectorFoundCount + ", total selector: " + CHALLENGE_SELECTORS.length)
|
||||||
|
if (selectorFoundCount == 0)
|
||||||
|
{
|
||||||
|
await page.close()
|
||||||
|
return ctx.errorResponse('No challenge selectors found, unable to proceed')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// it seems some captcha pages return 200 sometimes
|
// it seems some captcha pages return 200 sometimes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user