summaryrefslogtreecommitdiffstats
path: root/src/indeedwatcher.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/indeedwatcher.nim')
-rw-r--r--src/indeedwatcher.nim16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/indeedwatcher.nim b/src/indeedwatcher.nim
index 3fdb55a..9c280bb 100644
--- a/src/indeedwatcher.nim
+++ b/src/indeedwatcher.nim
@@ -7,6 +7,7 @@ import strutils
import parsetoml
import sequtils
import uri
+import json
if not fileExists(getConfigDir() & "/indeedwatcher/config.toml"):
createDir(getConfigDir() & "/indeedwatcher/")
@@ -16,7 +17,9 @@ if not fileExists(getConfigDir() & "/indeedwatcher/config.toml"):
#Port you wish chromedriver to use
port = 9515
#Location of chromedriver
- chromedriver = ""
+ chromedriver = "/usr/bin/chromedriver"
+ #If you would like headless mode enabled or not
+ headless = true
#Array of RSS urls that you wish the program to parse
feeds = [ \"https://rss.indeed.com/rss?q=Information%20Technology&l=Remote&jt=contract&explvl=entry_level\", \"https://rss.indeed.com/rss?q=Information%20Technology&l=Remote&jt=temporary&explvl=entry_level\"]
@@ -46,9 +49,15 @@ let cache = open(cachefileloc, fmAppend)
##Filtering section of config
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\""], } } } }
+else:
+ args = %*{"capabilities": {"browserName": "chrome"}}
#Webdriver
-let chromedriver = startProcess(chromedriverloc, "", ["--headless"])
+let chromedriver = startProcess(chromedriverloc)
sleep 5000
echo "connecting"
#TODO make the port configurable, some users may have something running here
@@ -71,7 +80,8 @@ proc terminate() {.noconv.} =
setControlCHook(terminate)
for feed in feeds:
- session = driver.createSession()
+ #let args = %*{"desiredCapabilities":{"browserName":"chromium"}}
+ session = driver.createSession(args)
if feedcounter > 3:
echo "resting for 20 seconds ..."
sleep 20000