Improve Cloudflare IP ban detection

This commit is contained in:
ngosang 2021-08-01 19:32:09 +02:00
parent 6dd8206a10
commit fdb3eae051

View File

@ -20,8 +20,8 @@ export default async function resolveChallenge(url: string, page: Page, response
}
log.info('Cloudflare detected');
if (await page.$('.cf-error-code')) {
throw new Error('Cloudflare has blocked this request (Code 1020 Detected).')
if (await page.$('span[data-translate="error"]') || (await page.content()).includes('error code: 1020')) {
throw new Error('Cloudflare has blocked this request. Probably your IP is banned for this site, check in your web browser.')
}
let selectorFoundCount = 0;