sdfsdf
This commit is contained in:
@@ -50,10 +50,7 @@ class SeleniumBrowser {
|
||||
return driver.get(uri)
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
.then(html => this.getHtml(html))
|
||||
.finally(() => {
|
||||
this.pool.release(driver)
|
||||
})
|
||||
.then(html => this.getHtml(driver, html))
|
||||
})
|
||||
} else {
|
||||
logger.info('URL %s is not valid', uri)
|
||||
@@ -62,15 +59,15 @@ class SeleniumBrowser {
|
||||
}
|
||||
}
|
||||
|
||||
async getHtml(html) {
|
||||
async getHtml(driver, html) {
|
||||
if (html.indexOf('grecaptcha') > -1 || html.indexOf('www.google.com/recaptcha/api2/anchor') > -1) {
|
||||
this.isRecaptchaReseponseEmpty = true
|
||||
let iframeSrc = await this.driver.findElement(By.css('#grecaptcha iframe')).getAttribute('src')
|
||||
let iframeSrc = await driver.findElement(By.css('#grecaptcha iframe')).getAttribute('src')
|
||||
let captcha2Params = {
|
||||
"key": "62fc5ef52fd4befe266d224796a7ea6f",
|
||||
"method": "userrecaptcha",
|
||||
"googlekey": url.parse(iframeSrc, true).query.k,
|
||||
"pageurl": await this.driver.getCurrentUrl(),
|
||||
"pageurl": await driver.getCurrentUrl(),
|
||||
"json": 1
|
||||
}
|
||||
let requestUrl = new url.URL('https://2captcha.com/in.php')
|
||||
@@ -90,12 +87,13 @@ class SeleniumBrowser {
|
||||
if (maxRetry == 0) break
|
||||
} while (res.request == 'CAPCHA_NOT_READY')
|
||||
this.isRecaptchaReseponseEmpty = false
|
||||
this.pool.release(driver)
|
||||
return res
|
||||
}).then(res => {
|
||||
logger.debug(res, '2captcha solved')
|
||||
this.driver.executeScript('captchaCallback("' + res.request + '")')
|
||||
this.driver.wait(10000).then(d => {
|
||||
this.driver.findElement(By.css('#g-recaptcha-response')).then(function (webElement) {
|
||||
driver.executeScript('captchaCallback("' + res.request + '")')
|
||||
driver.wait(10000).then(d => {
|
||||
driver.findElement(By.css('#g-recaptcha-response')).then(function (webElement) {
|
||||
logger.error(res, 'Failed to overcome recaptcha')
|
||||
}, function (err) {
|
||||
logger.info('Success to overcome recaptcha')
|
||||
@@ -103,9 +101,11 @@ class SeleniumBrowser {
|
||||
})
|
||||
}).catch(error => {
|
||||
logger.error({ message: error.message }, 'Error occured while process with 2captcha')
|
||||
this.pool.release(driver)
|
||||
})
|
||||
return ''
|
||||
} else {
|
||||
this.pool.release(driver)
|
||||
return html
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user