-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_asb.go
68 lines (52 loc) · 1.18 KB
/
source_asb.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
package main
import "github.com/gocolly/colly/v2"
type AsbJob struct {
Link string
Title string `selector:".title"`
Description string `selector:".description"`
Details string `selector:".details"`
}
func (job AsbJob) GetLink() string {
return job.Link
}
func (job AsbJob) GetTitle() string {
return job.Title
}
func (job AsbJob) GetDescription() string {
return job.Description
}
func (job AsbJob) GetType() string {
return job.Details
}
type Asb struct {
Container string
RequestMethod string
Jobs []IEntity
}
func AsbMakeSource() *Asb {
source := &Asb{}
source.RequestMethod = METHOD_GET
source.Container = ".job"
return source
}
func (asb *Asb) GetContainer() string {
return asb.Container
}
func (asb *Asb) GetRequestMethod() string {
return asb.RequestMethod
}
func (asb *Asb) GetRequestData() []byte {
return make([]byte, 0)
}
func (asb *Asb) GetQuery() string {
return ""
}
func (asb *Asb) GetOnHtmlHandler(e *colly.HTMLElement) {
job := AsbJob{}
e.Unmarshal(&job)
job.Link = e.Request.AbsoluteURL(e.Request.URL.Path)
asb.Jobs = append(asb.Jobs, job)
}
func (asb *Asb) GetOnScrapedHandler(data []byte) []IEntity {
return asb.Jobs
}