fsdfds
This commit is contained in:
@@ -14,16 +14,17 @@ 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.pool = pool.createPool({
|
this.pool = pool.createPool({
|
||||||
// create: () => {
|
create: () => {
|
||||||
// return this.getDriver();
|
return this.getDriver();
|
||||||
// },
|
},
|
||||||
// destroy: function (driver) {
|
destroy: function (driver) {
|
||||||
// driver.quit();
|
driver.close()
|
||||||
// }
|
driver.quit()
|
||||||
// }, {
|
}
|
||||||
// max: 10, min: 1
|
}, {
|
||||||
// });
|
max: 10, min: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getDriver() {
|
getDriver() {
|
||||||
@@ -41,15 +42,15 @@ 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()
|
return this.pool.acquire()
|
||||||
return this.getDriver()
|
// return this.getDriver()
|
||||||
.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.release(driver)
|
this.pool.destroy(driver)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
return html
|
return html
|
||||||
})
|
})
|
||||||
@@ -122,14 +123,9 @@ class SeleniumBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async close() {
|
async close() {
|
||||||
// this.pool.drain().then(function () {
|
this.pool.drain().then(function () {
|
||||||
// this.pool.clear();
|
this.pool.clear();
|
||||||
// })
|
})
|
||||||
}
|
|
||||||
|
|
||||||
loggingChrome() {
|
|
||||||
let logPath = __dirname + '/storage/chrome-logs.txt'
|
|
||||||
logger.info('Chrome logging into %s', logPath)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user