-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
30 lines (25 loc) · 1.03 KB
/
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
package main
import (
"flag"
"fmt"
"os"
"github.com/placer14/ob-crawler/crawler"
)
func main() {
var opts = crawler.CrawlOptions{}
flag.IntVar(&opts.MaxVisits, "max-visits", 0, "`maximum number of visits` the workers will make. 0 will allow the crawler to traverse the entire network")
flag.IntVar(&opts.ApiTimeout, "api-timeout", 60, "`time in seconds` to wait before abandoning a request")
flag.IntVar(&opts.ApiPort, "api-port", 4002, "`port` to use when connecting to OpenBazaar API")
flag.IntVar(&opts.WorkerPoolSize, "n", 10, "`number of concurrent crawlers` making API requests")
flag.StringVar(&opts.ApiHost, "api-host", "api", "`host` to use when connecting to OpenBazaar API")
flag.StringVar(&opts.AuthCookie, "auth-cookie", "", ".cookie `content` generated in OpenBazaar data path")
flag.Parse()
crawler := crawler.New(opts)
err := crawler.Execute()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("Complete.\nFound %d listings across %d nodes.\n", crawler.ListingCount(), crawler.NodesVisited())
os.Exit(0)
}