-
Notifications
You must be signed in to change notification settings - Fork 47
/
domain_collect.go
executable file
·38 lines (34 loc) · 1022 Bytes
/
domain_collect.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
package crawlergo
import (
"github.com/yhy0/Jie/crawler/crawlergo/model"
"strings"
mapset "github.com/deckarep/golang-set/v2"
)
func SubDomainCollect(reqList []*model.Request, HostLimit string) []string {
var subDomainList []string
uniqueSet := mapset.NewSet[string]()
for _, req := range reqList {
domain := req.URL.Hostname()
if uniqueSet.Contains(domain) {
continue
}
uniqueSet.Add(domain)
if strings.HasSuffix(domain, "."+HostLimit) {
subDomainList = append(subDomainList, domain)
}
}
return subDomainList
}
func AllDomainCollect(reqList []*model.Request) []string {
uniqueSet := mapset.NewSet[string]()
var allDomainList []string
for _, req := range reqList {
domain := req.URL.Hostname()
if uniqueSet.Contains(domain) {
continue
}
uniqueSet.Add(domain)
allDomainList = append(allDomainList, req.URL.Hostname())
}
return allDomainList
}