-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_hnz.go
95 lines (76 loc) · 1.66 KB
/
source_hnz.go
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
87
88
89
90
91
92
93
94
95
package main
import (
"encoding/json"
"log"
)
type HNZResponseRoot struct {
Rasp struct {
Jobs []struct {
Jobs []HNZJob `json:"jobs"`
} `json:"JOBS"`
} `json:"RASP"`
}
type Test struct {
Jobs struct {
Position string `json:"jobs"`
} `json:"jobs"`
}
type HNZJobsCollection struct {
Jobs []map[string]interface{} `json:"JOBS"`
}
type HNZJobsCollectionJobs struct {
Jobs []*HNZJob `json:"jobs"`
}
type HNZJob struct {
Link string `json:"href"`
Title string `json:"positionTitle"`
Island string `json:"island"`
Region string `json:"region"`
District string `json:"district"`
Closedate string `json:"closedate"`
Dateposted string `json:"dateposted"`
Type string `json:"jobtype"`
}
func (job HNZJob) GetLink() string {
return job.Link
}
func (job HNZJob) GetTitle() string {
return job.Title
}
func (job HNZJob) GetDescription() string {
return ""
}
func (job HNZJob) GetType() string {
return job.Type
}
type Hnz struct {
Container string
RequestMethod string
}
func HnzMakeSource() *Hnz {
source := &Hnz{}
source.RequestMethod = METHOD_GET
return source
}
func (hnz *Hnz) GetRequestMethod() string {
return hnz.RequestMethod
}
func (hnz *Hnz) GetRequestData() []byte {
return make([]byte, 0)
}
func (hnz *Hnz) GetQuery() string {
return ""
}
func (hnz *Hnz) GetOnScrapedHandler(data []byte) []IEntity {
parsedData := &HNZResponseRoot{}
err := json.Unmarshal(data, parsedData)
if err != nil {
log.Fatal(err)
}
entities := make([]IEntity, 0)
for _, job := range parsedData.Rasp.Jobs[0].Jobs {
job.Link = "https://jobs.tewhatuora.govt.nz" + job.Link
entities = append(entities, job)
}
return entities
}