sddsf
This commit is contained in:
@@ -40,7 +40,6 @@ class SeleniumBrowser {
|
|||||||
|
|
||||||
async request(params) {
|
async request(params) {
|
||||||
let uri = params.uri
|
let uri = params.uri
|
||||||
let waitElement = params.waitElement
|
|
||||||
if (this.isRecaptchaReseponseEmpty) {
|
if (this.isRecaptchaReseponseEmpty) {
|
||||||
return ''
|
return ''
|
||||||
} else {
|
} else {
|
||||||
@@ -50,7 +49,7 @@ class SeleniumBrowser {
|
|||||||
return driver.get(uri)
|
return driver.get(uri)
|
||||||
.then(() => driver.findElement(By.css('body')))
|
.then(() => driver.findElement(By.css('body')))
|
||||||
.then(body => body.getAttribute('innerHTML'))
|
.then(body => body.getAttribute('innerHTML'))
|
||||||
.then(html => this.getHtml(driver, html))
|
.then(html => this.getHtml(driver, html, params))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.info('URL %s is not valid', uri)
|
logger.info('URL %s is not valid', uri)
|
||||||
@@ -59,7 +58,7 @@ class SeleniumBrowser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getHtml(driver, html) {
|
async getHtml(driver, html, params) {
|
||||||
if (html.indexOf('grecaptcha') > -1 || html.indexOf('www.google.com/recaptcha/api2/anchor') > -1) {
|
if (html.indexOf('grecaptcha') > -1 || html.indexOf('www.google.com/recaptcha/api2/anchor') > -1) {
|
||||||
this.isRecaptchaReseponseEmpty = true
|
this.isRecaptchaReseponseEmpty = true
|
||||||
let iframeSrc = await driver.findElement(By.css('#grecaptcha iframe')).getAttribute('src')
|
let iframeSrc = await driver.findElement(By.css('#grecaptcha iframe')).getAttribute('src')
|
||||||
@@ -105,8 +104,14 @@ class SeleniumBrowser {
|
|||||||
})
|
})
|
||||||
return ''
|
return ''
|
||||||
} else {
|
} else {
|
||||||
this.pool.release(driver)
|
return driver.get(params.uri)
|
||||||
return html
|
.then(() => driver.wait(until.elementLocated(By.css(params.waitElement))))
|
||||||
|
.then(() => driver.findElement(By.css('body')))
|
||||||
|
.then(body => body.getAttribute('innerHTML'))
|
||||||
|
.then(html => {
|
||||||
|
this.pool.release(driver)
|
||||||
|
return html
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user