summaryrefslogtreecommitdiffstats
path: root/src/indeedwatcher.nim
blob: 1807e931545bc6feda62947fc7ca6afe45433a5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import rss
import webdriver
import osproc
import options
import os
import strutils

#Feednim
var test = getRSS("https://rss.indeed.com/rss?q=Linux&l=Arkansas&explvl=mid_level")
var URL = test.items[5].link

#Webdriver
#TODO put location of chromedriver into config
let chromedriver = startProcess("/usr/bin/chromedriver")
sleep 5000
echo "connecting"
let driver = newWebDriver("http://localhost:9515")
let session = driver.createSession()
session.navigate(URL)

#HTML Parser
var jobTimes: string
var salaryGuide: string

let jobTitle = session.findElement(".jobsearch-JobInfoHeader-title").get().getText()
let employer = session.findElement(".jobsearch-CompanyReview--heading").get().getText()

try:
    jobTimes = session.findElement(".jobsearch-JobDescriptionSection-sectionItem").get().getText()
except UnpackDefect:
    jobTimes = ""

try:
    salaryGuide = session.findelement("#salaryGuide").get().gettext()
except UnpackDefect:
    salaryGuide = "None Listed"

if salaryGuide.contains("Not provided by employer"):
    salaryGuide = "None Listed"

let fullDesc = session.findElement("#jobDescriptionText").get().getText()
session.close()
terminate(chromedriver)

#Job Value Scorer

#Parsing Salary

#Output
var output = """
\documentclass{article}
\usepackage[margin=0.7in]{geometry}
\usepackage{pdfpages}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=magenta,      
    urlcolor=blue,
    }


\begin{document}

\begin{center}
    \Huge{$1}
\end{center}
\hrulefill

    \large{$2} 
    \hspace{3cm}
    \large{$3} 
    \hspace{3cm}
    \large{\href{$4}{URL}} 
    \hspace{3cm}
    \large{$5}

\hrulefill

$6

\end{document}
""" % [jobTitle, employer, salaryGuide, URL.replace("&","\\&"), jobTimes, fullDesc.replace("#", "\\#").replace("&", "\\&").replace("\"", "\\\"").replace("'","\\'")]

writeFile("/tmp/test.tex", output)
discard execCmd( "latexmk -pdf -pvc /tmp/test.tex")