sdfdf
This commit is contained in:
@@ -102,13 +102,16 @@ class CaptchaComp {
|
||||
return res
|
||||
}
|
||||
|
||||
resolveCaptcha(driver) {
|
||||
resolveCaptcha(driver, pool) {
|
||||
return this.api.working ? new Promise(r => r(new Error('Resovling Catpcha'))) : this.requestResolve(driver)
|
||||
.then(id => this.getAnswer(id))
|
||||
.then(res => {
|
||||
setTimeout(() => { this.api.working = false }, 1000 * 5 * 2)
|
||||
logger.info({ result: res.request }, 'Calling captchaCallback')
|
||||
return driver.executeScript('captchaCallback("' + res.request + '")').then(() => this.sleep(1000 * 5))
|
||||
}).catch(err => {
|
||||
logger.error({ message: err.message }, 'Resolve captcha failed')
|
||||
pool.destroy(driver)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class SeleniumBrowser {
|
||||
let html = await driver.get(uri)
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
let p = captcha.isCaptchaPage(html) ? captcha.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||
let p = captcha.isCaptchaPage(html) ? captcha.resolveCaptcha(driver, this.pool) : this.getHtml(driver, html, params)
|
||||
html = await p
|
||||
if (this.pool.isBorrowedResource(driver)) this.pool.release(driver)
|
||||
return html
|
||||
|
||||
Reference in New Issue
Block a user