sdf
This commit is contained in:
@@ -19,6 +19,7 @@ class SeleniumBrowser {
|
|||||||
return this.getDriver();
|
return this.getDriver();
|
||||||
},
|
},
|
||||||
destroy: function (driver) {
|
destroy: function (driver) {
|
||||||
|
driver.close()
|
||||||
driver.quit()
|
driver.quit()
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@@ -35,6 +36,11 @@ class SeleniumBrowser {
|
|||||||
this.pool.on('factoryDestroyError', function (err) {
|
this.pool.on('factoryDestroyError', function (err) {
|
||||||
logger.error(err.message, 'pool error')
|
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() {
|
getDriver() {
|
||||||
@@ -60,8 +66,9 @@ class SeleniumBrowser {
|
|||||||
.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
|
||||||
|
driver.close()
|
||||||
|
driver.quit()
|
||||||
this.pool.destroy(driver)
|
this.pool.destroy(driver)
|
||||||
this.pool.release(driver)
|
|
||||||
return html
|
return html
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user