cloudflare-scraper
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,5 +5,7 @@ const request = require('request-promise-native'); | ||
const fillCookiesJar = require('./src/fillCookiesJar'); | ||
const { isCloudflareJSChallenge, isCloudflareCaptchaChallenge } = require('./src/utils'); | ||
function isCloudflareIUAMError(error) { | ||
return error.response.body.includes('cf-browser-verification'); | ||
const { body } = error.response; | ||
return isCloudflareJSChallenge(body) || isCloudflareCaptchaChallenge(body); | ||
} | ||
@@ -10,0 +12,0 @@ |
{ | ||
"name": "cloudflare-scraper", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A package to bypass Cloudflare's protection", | ||
@@ -5,0 +5,0 @@ "author": "Jimmy Laurent", |
@@ -6,2 +6,3 @@ const puppeteer = require('puppeteer-extra'); | ||
const handleCaptcha = require('./handleCaptcha'); | ||
const { isCloudflareJSChallenge, isCloudflareCaptchaChallenge } = require('./utils'); | ||
@@ -55,18 +56,21 @@ puppeteer.use(StealthPlugin()); | ||
let content = await page.content(); | ||
while (content.includes('cf-browser-verification')) { | ||
response = await page.waitForNavigation({ | ||
timeout: 45000, | ||
waitUntil: 'domcontentloaded' | ||
}); | ||
content = await page.content(); | ||
if (count++ === 10) { | ||
throw new Error('timeout on just a moment'); | ||
if (isCloudflareCaptchaChallenge(content)) { | ||
await handleCaptcha(content, request, options); | ||
} | ||
else { | ||
while (isCloudflareJSChallenge(content)) { | ||
response = await page.waitForNavigation({ | ||
timeout: 45000, | ||
waitUntil: 'domcontentloaded' | ||
}); | ||
content = await page.content(); | ||
if (count++ === 10) { | ||
throw new Error('timeout on just a moment'); | ||
} | ||
} | ||
if (isCloudflareCaptchaChallenge(content)) { | ||
await handleCaptcha(content, request, options); | ||
} | ||
} | ||
content = await page.content(); | ||
if (content.includes('cf_captcha_kind')) { | ||
await handleCaptcha(content, request, options); | ||
} | ||
const cookies = await page.cookies(); | ||
@@ -73,0 +77,0 @@ for (let cookie of cookies) { |
@@ -1,2 +0,1 @@ | ||
function extract(string, regexp, errorMessage) { | ||
@@ -12,2 +11,10 @@ const match = string.match(regexp); | ||
module.exports = { extract }; | ||
function isCloudflareJSChallenge(body) { | ||
return body.includes('cf-browser-verification'); | ||
} | ||
function isCloudflareCaptchaChallenge(body) { | ||
return body.includes('cf_captcha_kind'); | ||
} | ||
module.exports = { extract, isCloudflareJSChallenge, isCloudflareCaptchaChallenge }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9816
203
0