sdfsdf
This commit is contained in:
@@ -16,21 +16,6 @@ class SeleniumBrowser {
|
||||
this.capabilities = Capabilities.chrome()
|
||||
this.sleep = m => new Promise(r => setTimeout(r, m))
|
||||
this.createPool()
|
||||
// setInterval(() => this.reCreatePool(), 1000 * 60 * 3)
|
||||
}
|
||||
|
||||
reCreatePool() {
|
||||
delete this.pool
|
||||
this.pool = null
|
||||
this.createPool
|
||||
// this.pool.drain().then(() => {
|
||||
// return this.pool.clear()
|
||||
// }).catch(err => {
|
||||
// logger.debug({message: err.message}, 'Pool draining error')
|
||||
// return this.pool.clear()
|
||||
// }).then(() => {
|
||||
// this.createPool()
|
||||
// })
|
||||
}
|
||||
|
||||
createPool() {
|
||||
@@ -57,7 +42,7 @@ class SeleniumBrowser {
|
||||
})
|
||||
}
|
||||
}, {
|
||||
max: 2, min: 1, testOnBorrow: true
|
||||
max: 20, min: 1, testOnBorrow: true
|
||||
});
|
||||
|
||||
this.pool.on('factoryCreateError', function (err) {
|
||||
@@ -76,7 +61,7 @@ class SeleniumBrowser {
|
||||
borrowed: this.pool.borrowed,
|
||||
pending: this.pool.pending
|
||||
}, 'Pool info')
|
||||
}, 5000)
|
||||
}, 1000 * 60 * 5)
|
||||
}
|
||||
|
||||
getDriver() {
|
||||
@@ -98,13 +83,7 @@ class SeleniumBrowser {
|
||||
.then(async driver => {
|
||||
let html = await driver.get(uri)
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML')).catch(err => {
|
||||
return false
|
||||
})
|
||||
if(!html) {
|
||||
this.pool.release(driver)
|
||||
throw new Error('Init try got Empty html')
|
||||
}
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||
html = await htmlPromise
|
||||
this.pool.destroy(driver)
|
||||
|
||||
Reference in New Issue
Block a user