fsdf
This commit is contained in:
@@ -92,16 +92,20 @@ class SeleniumBrowser {
|
|||||||
let uri = params.uri
|
let uri = params.uri
|
||||||
logger.info('URL %s', uri)
|
logger.info('URL %s', uri)
|
||||||
if (uri.indexOf('://') > 3) {
|
if (uri.indexOf('://') > 3) {
|
||||||
return this.pool.acquire()
|
if (this.pool) {
|
||||||
.then(async driver => {
|
return this.pool.acquire()
|
||||||
let html = await driver.get(uri)
|
.then(async driver => {
|
||||||
.then(() => driver.findElement(By.css('body')))
|
let html = await driver.get(uri)
|
||||||
.then(body => body.getAttribute('innerHTML'))
|
.then(() => driver.findElement(By.css('body')))
|
||||||
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
.then(body => body.getAttribute('innerHTML'))
|
||||||
html = await htmlPromise
|
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||||
this.pool.destroy(driver)
|
html = await htmlPromise
|
||||||
return html
|
this.pool.destroy(driver)
|
||||||
})
|
return html
|
||||||
|
})
|
||||||
|
}else {
|
||||||
|
throw new Error('Pool is not ready')
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid URI - ' + uri)
|
throw new Error('Invalid URI - ' + uri)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user