figured out what is until
This commit is contained in:
@@ -35,15 +35,29 @@ class SeleniumBrowser {
|
||||
return new Builder().forBrowser(this.config.browser).setChromeOptions(opts).build();
|
||||
}
|
||||
|
||||
async request(uri) {
|
||||
request(uri, waitElement) {
|
||||
if (this.isRecaptchaReseponseEmpty) {
|
||||
return ''
|
||||
} else {
|
||||
logger.info('URL %s', uri)
|
||||
if (uri.indexOf('://') > 3) {
|
||||
return this.driver.get(uri).then(d => this.driver.findElement(By.css('body')).getAttribute('innerHTML'))
|
||||
return this.driver.get(uri)
|
||||
// .then(() => {
|
||||
// if (waitElement) {
|
||||
// return this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css(waitElement))), 5 * 1000)
|
||||
// }
|
||||
// return true
|
||||
// })
|
||||
.then(() => this.driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
.then(html => this.getHtml(html))
|
||||
}else {
|
||||
// .catch(error => {
|
||||
// logger.error({ message: error.message }, 'No image element')
|
||||
// return this.driver.findElement(By.css('body'))
|
||||
// .then(body => body.getAttribute('innerHTML'))
|
||||
// .then(html => this.getHtml(html))
|
||||
// })
|
||||
} else {
|
||||
logger.info('URL %s is not valid', uri)
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ class HeadlessService {
|
||||
|
||||
}
|
||||
|
||||
real(url) {
|
||||
return browser.request(url)
|
||||
get(uri, waitElement) {
|
||||
return browser.request(uri, waitElement)
|
||||
}
|
||||
|
||||
close() {
|
||||
|
||||
Reference in New Issue
Block a user