mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-13 14:57:21 +00:00
parent
805a34c9d6
commit
c6677f4d84
@ -77,7 +77,7 @@ function errorResponse(errorMsg: string, res: ServerResponse, startTimestamp: nu
|
|||||||
|
|
||||||
function successResponse(successMsg: string, extendedProperties: object, res: ServerResponse, startTimestamp: number) {
|
function successResponse(successMsg: string, extendedProperties: object, res: ServerResponse, startTimestamp: number) {
|
||||||
const endTimestamp = Date.now()
|
const endTimestamp = Date.now()
|
||||||
log.info(`Successful response in ${(endTimestamp - startTimestamp) / 1000} s`)
|
log.info(`Response in ${(endTimestamp - startTimestamp) / 1000} s`)
|
||||||
if (successMsg) { log.info(successMsg) }
|
if (successMsg) { log.info(successMsg) }
|
||||||
|
|
||||||
const response = Object.assign({
|
const response = Object.assign({
|
||||||
|
@ -8,7 +8,7 @@ import getCaptchaSolver, {CaptchaType} from "../captcha";
|
|||||||
* This class contains the logic to solve protections provided by CloudFlare
|
* This class contains the logic to solve protections provided by CloudFlare
|
||||||
**/
|
**/
|
||||||
|
|
||||||
const CHALLENGE_SELECTORS = ['#trk_jschal_js', '.ray_id', '.attack-box'];
|
const CHALLENGE_SELECTORS = ['#trk_jschal_js', '.ray_id', '.attack-box', '#cf-please-wait'];
|
||||||
const TOKEN_INPUT_NAMES = ['g-recaptcha-response', 'h-captcha-response'];
|
const TOKEN_INPUT_NAMES = ['g-recaptcha-response', 'h-captcha-response'];
|
||||||
|
|
||||||
export default async function resolveChallenge(url: string, page: Page, response: Response): Promise<Response> {
|
export default async function resolveChallenge(url: string, page: Page, response: Response): Promise<Response> {
|
||||||
@ -38,16 +38,30 @@ export default async function resolveChallenge(url: string, page: Page, response
|
|||||||
await page.waitFor(1000)
|
await page.waitFor(1000)
|
||||||
try {
|
try {
|
||||||
// catch exception timeout in waitForNavigation
|
// catch exception timeout in waitForNavigation
|
||||||
response = await page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 5000 })
|
response = await page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 9000 })
|
||||||
} catch (error) { }
|
} catch (error) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// catch Execution context was destroyed
|
// catch Execution context was destroyed
|
||||||
const cfChallengeElem = await page.$(selector)
|
const cfChallengeElem = await page.$(selector)
|
||||||
if (!cfChallengeElem) { break }
|
if (!cfChallengeElem) {
|
||||||
|
// solved!
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
const displayStyle = await page.evaluate((selector) => {
|
||||||
|
return getComputedStyle(document.querySelector(selector)).getPropertyValue("display");
|
||||||
|
}, selector);
|
||||||
|
if (displayStyle == "none") {
|
||||||
|
// spinner is hidden, could be a captcha or not
|
||||||
|
await page.waitFor(1000)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
log.debug('Found challenge element again...')
|
log.debug('Found challenge element again...')
|
||||||
} catch (error)
|
} catch (error)
|
||||||
{ }
|
{
|
||||||
|
log.debug("Unexpected error: " + error);
|
||||||
|
}
|
||||||
|
|
||||||
response = await page.reload({ waitUntil: 'domcontentloaded' })
|
response = await page.reload({ waitUntil: 'domcontentloaded' })
|
||||||
log.debug('Page reloaded.')
|
log.debug('Page reloaded.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user