forked from Loyalsoldier/cn-blocked-domain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (38 loc) · 848 Bytes
/
main.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
package main
import (
"flag"
"log"
"os"
)
var configFile = flag.String("c", "config.yaml", "Path to the configuration file, supports YAML and JSON.")
func init() {
flag.Parse()
}
func main() {
rawConfig := new(RawConfig)
config := new(Config)
if err := rawConfig.ParseRawConfig(*configFile); err != nil {
log.Fatal(err)
os.Exit(1)
}
if err := config.GenerateConfig(rawConfig); err != nil {
log.Fatal(err)
os.Exit(2)
}
if err := config.SetNumCPU(); err != nil {
log.Fatal(err)
os.Exit(3)
}
for err := range config.CrawlMaxPage() {
log.Fatal(err)
os.Exit(4)
}
if err := config.GenerateCrawlList(); err != nil {
log.Fatal(err)
os.Exit(5)
}
maxCap := config.Customize.MaxCapacity
rawResultChan := make(chan map[*string]int, maxCap)
go config.Crawl(rawResultChan)
config.FilterAndWrite(rawResultChan)
}