Colorized output
This commit is contained in:
parent
dfecf65ba9
commit
c3929aff1d
@ -36,6 +36,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/fatih/color"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
@ -274,17 +275,21 @@ func main() {
|
||||
webcachePath := flag.String("webcache", "cache/webcache", "web data cache")
|
||||
flag.Parse()
|
||||
|
||||
log.Print(color.BlueString("scraping data..."))
|
||||
reviews, err := scrapeData(*urlsPath, *geocachePath, *webcachePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Print(color.BlueString("collating data..."))
|
||||
restaurants := collateData(reviews)
|
||||
|
||||
log.Print(color.BlueString("computing station data..."))
|
||||
if err := computeStnData(restaurants, *stationsPath); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Print(color.BlueString("saving data..."))
|
||||
if err := dumpData(*dbPath, restaurants); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
type feature struct {
|
||||
@ -159,10 +160,10 @@ func scrape(url string, scr scraper) ([]review, error) {
|
||||
defer wg.Done()
|
||||
for rev := range out {
|
||||
if rev.err == nil {
|
||||
log.Printf("SUCCESS: %s", rev.name)
|
||||
log.Print(color.GreenString(rev.name))
|
||||
reviews = append(reviews, rev)
|
||||
} else {
|
||||
log.Printf("FAIL: %s", rev.name)
|
||||
log.Printf("%s (%s)", color.YellowString(rev.name), color.RedString(rev.err.Error()))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user