-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
56 lines (43 loc) · 1.08 KB
/
main.go
File metadata and controls
56 lines (43 loc) · 1.08 KB
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
/*
WebCrawler
*/
package main
import (
"flag"
"os"
"os/signal"
l "github.com/acky666/ackyLog"
Crawler "github.com/acky666/WebCrawler/Crawler"
)
func main() {
// As this can take a long time, Catch the Control C and Print out the Progress so far.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
// Print Progress and Exit
go func() {
oscall := <-c
l.WARNING("User or System Interupted: %v, dumping progress so far. ", oscall)
Crawler.Results()
os.Exit(1)
}()
URLtoCrawl := flag.String("url", "", "The URL to Crawl")
Concurrent := flag.Int("c", 10, "Max number of Concurrent Goroutines")
Debug := flag.Bool("debug", true, "Display Debug messages")
flag.Parse()
if *Debug {
l.SHOWDEBUG = true
}
// Nothing Specified
if *URLtoCrawl == "" {
l.INFO("Please specify a URL on using the -url command argument\n")
os.Exit(1)
}
// Start Crawling!
l.INFO("Crawling '%s'\n", *URLtoCrawl)
// Add the Starting URL (the one from the command line)
Crawler.AllLinks.Add(*URLtoCrawl)
// Go Go Go
Crawler.Go(*Concurrent)
// Output Results
Crawler.Results()
}