From e3d871381ffd4414f895ee2590bbb44e2fa04dde Mon Sep 17 00:00:00 2001 From: msglm Date: Fri, 17 Feb 2023 03:11:26 -0600 Subject: port preference is definable in config --- src/indeedwatcher.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/indeedwatcher.nim b/src/indeedwatcher.nim index 9c280bb..0fc8af4 100644 --- a/src/indeedwatcher.nim +++ b/src/indeedwatcher.nim @@ -40,7 +40,7 @@ let config = parsetoml.parseFile(getConfigDir() & "/indeedwatcher/config.toml") ##Main section of config let feeds = config["feeds"].getElems().mapIt(it.getStr()) let outdir = config["outdir"].getStr() - +let driverURL = "http://localhost:" & config["port"].getInt().intToStr() ##Cache section of config let chromedriverloc = config["chromedriver"].getStr() let cachefileloc = getCacheDir() & "/indeedwatcher/listings.cache" @@ -52,16 +52,17 @@ let titleblacklist = config["blacklist"]["title"].getElems().mapIt(it.getStr()) ##Does the user desire headlessness? var args: JsonNode if config["headless"].getBool(): - args = %*{ "capabilities": {"alwaysMatch": { "goog:chromeOptions": { "args": ["--headless", "--lang=en_US", "--window-size=1920,1080", "--start-maximized", "--user-agent=\"Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/109.0\""], } } } } + args = %*{ "capabilities": {"alwaysMatch": { "goog:chromeOptions": { "args": ["headless", "lang=en_US", "window-size=1920,1080", "start-maximized", "user-agent=\"Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/109.0\""], } } } } + else: - args = %*{"capabilities": {"browserName": "chrome"}} + args = %*{ "capabilities": {"alwaysMatch": { "goog:chromeOptions": { "args": ["start-maximized"] } } } } #Webdriver let chromedriver = startProcess(chromedriverloc) sleep 5000 echo "connecting" #TODO make the port configurable, some users may have something running here -let driver = newWebDriver("http://localhost:9515") +let driver = newWebDriver(driverURL) var session: Session var feedcounter = 0 var urlcounter = 0 -- cgit v1.2.3