dsfsdf
This commit is contained in:
@@ -16,7 +16,7 @@ class SeleniumBrowser {
|
|||||||
this.capabilities = Capabilities.chrome()
|
this.capabilities = Capabilities.chrome()
|
||||||
this.sleep = m => new Promise(r => setTimeout(r, m))
|
this.sleep = m => new Promise(r => setTimeout(r, m))
|
||||||
this.createPool()
|
this.createPool()
|
||||||
setInterval(() => this.reCreatePool(), 1000 * 60 * 3)
|
// setInterval(() => this.reCreatePool(), 1000 * 60 * 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
reCreatePool() {
|
reCreatePool() {
|
||||||
@@ -92,20 +92,20 @@ 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) {
|
||||||
if (this.pool) {
|
// if (this.pool) {
|
||||||
return this.pool.acquire()
|
return this.pool.acquire()
|
||||||
.then(async driver => {
|
.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.destroy(driver)
|
this.pool.destroy(driver)
|
||||||
return html
|
return html
|
||||||
})
|
})
|
||||||
}else {
|
// }else {
|
||||||
throw new Error('Pool is not ready')
|
// throw new Error('Pool is not ready')
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid URI - ' + uri)
|
throw new Error('Invalid URI - ' + uri)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user