From 998dc39f3fd7bd5a02c15ca59b1c2d76d4396c66 Mon Sep 17 00:00:00 2001 From: spiduler Date: Sun, 25 Oct 2020 03:49:38 +0900 Subject: [PATCH] fsdf --- src/component/SeleniumBrowser.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/component/SeleniumBrowser.js b/src/component/SeleniumBrowser.js index 3948638..4955dcc 100644 --- a/src/component/SeleniumBrowser.js +++ b/src/component/SeleniumBrowser.js @@ -92,16 +92,20 @@ class SeleniumBrowser { let uri = params.uri logger.info('URL %s', uri) if (uri.indexOf('://') > 3) { - return this.pool.acquire() - .then(async driver => { - let html = await driver.get(uri) - .then(() => driver.findElement(By.css('body'))) - .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) - return html - }) + if (this.pool) { + return this.pool.acquire() + .then(async driver => { + let html = await driver.get(uri) + .then(() => driver.findElement(By.css('body'))) + .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) + return html + }) + }else { + throw new Error('Pool is not ready') + } } else { throw new Error('Invalid URI - ' + uri) }