summaryrefslogtreecommitdiff
path: root/data/configs/indeed.go
blob: d1ba4e4e3c67338b5451ed682be4a11b7cce305b (plain)
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
package configs

import (
	"log/slog"

	"github.com/Wacky404/lurchers/data"

	"github.com/gocolly/colly"
)

type CollyCfg struct {
	C    *colly.Collector
	Data *data.Job
}

func newCollyCfg() *CollyCfg {
	return &CollyCfg{
		C:    colly.NewCollector(colly.Async(true)),
		Data: data.NewJob(),
	}
}

func IndeedConfig() *CollyCfg {
	cfg := newCollyCfg()
	cfg.Data.Posting.Website = "https://indeed.com/"
	// testing this out; will need to build this
	cfg.Data.Posting.Url = "https://www.indeed.com/jobs?q=%2B&l=Little+Rock%2C+AR&fromage=7&salaryType=%2440%2C000%2B&radius=5&jlid=68f779f7b0e38e09&rbl=Little+Rock%2C+AR&from=searchOnDesktopSerp&vjk=7a14f77130c03202"
	cfg.C.OnHTML("a[id^='job_']", func(e *colly.HTMLElement) {
		link := e.Attr("href")
		cfg.C.Visit(e.Request.AbsoluteURL(link))
	})
	cfg.C.OnHTML("h1[class^='jobserch-JobInfoHeader-title']", func(e *colly.HTMLElement) {
		jobPosition := e.Text
		slog.Info("Job Found", slog.String("Position", jobPosition))
	})

	return cfg
}