diff options
| author | horus | 2018-02-16 18:06:50 +0100 |
|---|---|---|
| committer | horus | 2018-02-16 18:06:50 +0100 |
| commit | bf5f6b98a1d933d5f0ffb7fe965428f4dab5e3b0 (patch) | |
| tree | c95eb6426b61965b37da2b60da36cfe2c02a92b4 /crawler/shop_whiskyworld.go | |
| parent | ed6ab4da59f80bf9fa2cbf15da5c9167dff44ea4 (diff) | |
| download | alkobote-bf5f6b98a1d933d5f0ffb7fe965428f4dab5e3b0.tar.gz | |
Structured logging part two. (crawler)
Diffstat (limited to 'crawler/shop_whiskyworld.go')
| -rw-r--r-- | crawler/shop_whiskyworld.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/crawler/shop_whiskyworld.go b/crawler/shop_whiskyworld.go index 9b968a3..5235d3c 100644 --- a/crawler/shop_whiskyworld.go +++ b/crawler/shop_whiskyworld.go @@ -1,7 +1,6 @@ package main import ( - log "github.com/Sirupsen/logrus" "strings" "github.com/gocolly/colly" @@ -43,15 +42,13 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { W.Original_price, err = convert_price(regular_price) if err != nil { - log.Println("Whisky World: Original_price failed: " + regular_price + " // " + W.Name + " // " + W.Url + " // " + e.Request.URL.String()) - log.Fatal(err) + Fatal(err, "Whiskyworld: Converting original price failed") return } W.Discounted_price, err = convert_price(e.ChildText(".uvp")) if err != nil { - log.Println("Whisky World: Discounted_price failed") - log.Fatal(err) + Fatal(err, "Whiskyworld: Converting discounted price failed") return } @@ -59,13 +56,13 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { text_noisy := e.ChildText(".item-inh") W.Volume, err = extract_volume(text_noisy) if err != nil { - log.Fatal(err) + Fatal(err, "Whiskyworld: Extracting volume failed") } abv_noisy := strings.TrimSpace(strings.SplitAfter(text_noisy, "Liter")[1]) abv_noisy = strings.TrimPrefix(abv_noisy, "/") W.Abv, err = extract_abv(abv_noisy) if err != nil { - log.Fatal(err) + Fatal(err, "Whiskyworld: Extracting abv failed") } }) @@ -75,8 +72,7 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { base_price_noisy = strings.TrimSpace(strings.SplitAfter(base_price_noisy, "Liter")[0]) W.Base_price, err = sanitize_base_price(base_price_noisy) if err != nil { - log.Println("Whisky World: Base_price failed") - log.Fatal(err) + Fatal(err, "Whiskyworld: Sanitizing base price failed") } } @@ -87,6 +83,15 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { W.Shop = shop.Id W.Spirit_type = "Whisky" + if W.Volume == 0 { + DebugOffer(W, "Whiskyworld: Volume is zero") + return + } + if W.Abv == 0 { + DebugOffer(W, "Whiskyworld: Abv is zero") + return + } + e.Request.Visit(W.Url) W.Website = e.Request.Ctx.Get("website") |
