sdfdsf
This commit is contained in:
@@ -7,20 +7,22 @@ const logger = require("logops")
|
|||||||
, { Options } = require('selenium-webdriver/chrome');
|
, { Options } = require('selenium-webdriver/chrome');
|
||||||
|
|
||||||
class SeleniumBrowser {
|
class SeleniumBrowser {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.config = { useHub: true, browser: 'chrome' }
|
this.config = {
|
||||||
|
useHub: true, browser: 'chrome',
|
||||||
|
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=spiduler-tor:8118']
|
||||||
|
}
|
||||||
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.isRecaptchaReseponseEmpty = false
|
this.isRecaptchaReseponseEmpty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
getDriver() {
|
getDriver() {
|
||||||
let opts = new Options;
|
let opts = new Options;
|
||||||
opts.addArguments(this.getChromeArgs())
|
opts.addArguments(this.config.browserArgs)
|
||||||
return new Builder()
|
return new Builder()
|
||||||
.usingServer('http://spiduler-chrome:4444/wd/hub')
|
.usingServer('http://spiduler-chrome:4444/wd/hub')
|
||||||
.withCapabilities(this.capabilities)
|
.withCapabilities(this.capabilities)
|
||||||
.setProxy(proxy.manual({http: 'spiduler-tor:8118'}))
|
|
||||||
.forBrowser(this.config.browser)
|
.forBrowser(this.config.browser)
|
||||||
.setChromeOptions(opts)
|
.setChromeOptions(opts)
|
||||||
.build();
|
.build();
|
||||||
@@ -116,17 +118,6 @@ class SeleniumBrowser {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getChromeArgs() {
|
|
||||||
let args = ['--no-sandbox', '--headless', '--disable-dev-shm-usage']
|
|
||||||
if (config.proxy) {
|
|
||||||
args.push('--proxy-server=' + config.proxy)
|
|
||||||
}
|
|
||||||
if (config.chrome) {
|
|
||||||
config.chrome.split(' ').map(a => args.push('--' + a))
|
|
||||||
}
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
loggingChrome() {
|
loggingChrome() {
|
||||||
let logPath = __dirname + '/storage/chrome-logs.txt'
|
let logPath = __dirname + '/storage/chrome-logs.txt'
|
||||||
logger.info('Chrome logging into %s', logPath)
|
logger.info('Chrome logging into %s', logPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user