This commit is contained in:
spiduler
2020-10-23 04:05:01 +09:00
parent f413cc51e7
commit 43755104d5

View File

@@ -19,6 +19,7 @@ class SeleniumBrowser {
return this.getDriver();
},
destroy: function (driver) {
driver.close()
driver.quit()
}
}, {
@@ -35,6 +36,11 @@ class SeleniumBrowser {
this.pool.on('factoryDestroyError', function (err) {
logger.error(err.message, 'pool error')
})
this.pool.use(async driver => {
let session = await driver.getSession()
return session && session.getId() ? driver : this.getDriver()
}).then(/* a promise that will run after myTask resolves */)
}
getDriver() {
@@ -60,8 +66,9 @@ class SeleniumBrowser {
.then(body => body.getAttribute('innerHTML'))
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
html = await htmlPromise
driver.close()
driver.quit()
this.pool.destroy(driver)
this.pool.release(driver)
return html
})
} else {