This commit is contained in:
spiduler
2020-10-22 13:32:07 +09:00
parent 31f01f0dfa
commit 6e180779e4

View File

@@ -41,15 +41,18 @@ class SeleniumBrowser {
let uri = params.uri
logger.info('URL %s', uri)
if (uri.indexOf('://') > 3) {
return this.pool.acquire().then(async driver => {
let html = await driver.get(uri)
.then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML'))
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
html = await htmlPromise
this.pool.release(driver)
return html
})
// return this.pool.acquire()
return this.getDriver()
.then(async driver => {
let html = await driver.get(uri)
.then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML'))
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
html = await htmlPromise
// this.pool.release(driver)
driver.quit()
return html
})
} else {
throw new Error('Invalid URI - ' + uri)
}