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

View File

@@ -41,13 +41,16 @@ 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().then(async driver => { // return this.pool.acquire()
return this.getDriver()
.then(async driver => {
let html = await driver.get(uri) let html = await 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'))
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params) let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
html = await htmlPromise html = await htmlPromise
this.pool.release(driver) // this.pool.release(driver)
driver.quit()
return html return html
}) })
} else { } else {