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 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()
let html = await driver.get(uri) return this.getDriver()
.then(() => driver.findElement(By.css('body'))) .then(async driver => {
.then(body => body.getAttribute('innerHTML')) let html = await driver.get(uri)
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params) .then(() => driver.findElement(By.css('body')))
html = await htmlPromise .then(body => body.getAttribute('innerHTML'))
this.pool.release(driver) let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
return html html = await htmlPromise
}) // this.pool.release(driver)
driver.quit()
return html
})
} else { } else {
throw new Error('Invalid URI - ' + uri) throw new Error('Invalid URI - ' + uri)
} }