fdgfg
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const logging = require("express-logging")
|
||||
const logger = require("logops")
|
||||
, { By } = require('selenium-webdriver')
|
||||
, url = require('url')
|
||||
@@ -12,7 +13,8 @@ class CaptchaComp {
|
||||
in: 'https://2captcha.com/in.php',
|
||||
res: 'https://2captcha.com/res.php',
|
||||
key: "62fc5ef52fd4befe266d224796a7ea6f",
|
||||
retryTimeout: 5000
|
||||
retryTimeout: 5000,
|
||||
working: false
|
||||
}
|
||||
this.params = {
|
||||
in: {
|
||||
@@ -93,9 +95,11 @@ class CaptchaComp {
|
||||
}
|
||||
|
||||
resolveCaptcha(driver) {
|
||||
return this.requestResolve(driver)
|
||||
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))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ class SeleniumBrowser {
|
||||
let html = await driver.get(uri)
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
let htmlPromise = captcha.isCaptchaPage(html) ? captcha.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||
html = await htmlPromise
|
||||
let p = captcha.isCaptchaPage(html) ? captcha.resolveCaptcha(driver) : 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