This commit is contained in:
spiduler
2020-10-21 17:18:00 +09:00
parent 03be96b3e4
commit 6e6dcbf6d6

View File

@@ -40,7 +40,6 @@ class SeleniumBrowser {
async request(params) {
let uri = params.uri
let waitElement = params.waitElement
if (this.isRecaptchaReseponseEmpty) {
return ''
} else {
@@ -50,7 +49,7 @@ class SeleniumBrowser {
return driver.get(uri)
.then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML'))
.then(html => this.getHtml(driver, html))
.then(html => this.getHtml(driver, html, params))
})
} else {
logger.info('URL %s is not valid', uri)
@@ -59,7 +58,7 @@ class SeleniumBrowser {
}
}
async getHtml(driver, html) {
async getHtml(driver, html, params) {
if (html.indexOf('grecaptcha') > -1 || html.indexOf('www.google.com/recaptcha/api2/anchor') > -1) {
this.isRecaptchaReseponseEmpty = true
let iframeSrc = await driver.findElement(By.css('#grecaptcha iframe')).getAttribute('src')
@@ -105,8 +104,14 @@ class SeleniumBrowser {
})
return ''
} else {
return driver.get(params.uri)
.then(() => driver.wait(until.elementLocated(By.css(params.waitElement))))
.then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML'))
.then(html => {
this.pool.release(driver)
return html
})
}
}