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_bottleworld.go | |
| parent | ed6ab4da59f80bf9fa2cbf15da5c9167dff44ea4 (diff) | |
| download | alkobote-bf5f6b98a1d933d5f0ffb7fe965428f4dab5e3b0.tar.gz | |
Structured logging part two. (crawler)
Diffstat (limited to 'crawler/shop_bottleworld.go')
| -rw-r--r-- | crawler/shop_bottleworld.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/crawler/shop_bottleworld.go b/crawler/shop_bottleworld.go index 2eea3e5..db45791 100644 --- a/crawler/shop_bottleworld.go +++ b/crawler/shop_bottleworld.go @@ -1,7 +1,6 @@ package main import ( - log "github.com/Sirupsen/logrus" "regexp" "strings" @@ -33,13 +32,13 @@ func ScrapeBottleWord(shop Shop) []Angebot { e.ForEach(".old-price", func(i int, e *colly.HTMLElement) { W.Original_price, err = convert_price(e.ChildText(".price")) if err != nil { - log.Fatal(err) + Fatal(err, "Bottleworld: Converting original price failed") } }) e.ForEach(".special-price", func(i int, e *colly.HTMLElement) { W.Discounted_price, err = convert_price(e.ChildText(".price")) if err != nil { - log.Fatal(err) + Fatal(err, "Bottleworld: Converting discounted price failed") } }) }) @@ -47,7 +46,7 @@ func ScrapeBottleWord(shop Shop) []Angebot { price_per_litre_noisy := e.ChildText(".price-per-liter") price_per_litre, err := sanitize_base_price(price_per_litre_noisy) if err != nil { - log.Fatal(err) + Fatal(err, "Bottleworld: Sanitizing base price failed") } W.Base_price = price_per_litre @@ -58,7 +57,15 @@ func ScrapeBottleWord(shop Shop) []Angebot { W.Shop = shop.Id W.Volume = get_volume(e) + if W.Volume == 0 { + DebugOffer(W, "Bottleworld: Volume is zero") + return + } W.Abv = get_abv(e) + if W.Abv == 0 { + DebugOffer(W, "Bottleworld: Abv is zero") + return + } W.Spirit_type = e.Request.Ctx.Get("spirit_type") W.Website = e.Request.Ctx.Get("website") @@ -71,7 +78,7 @@ func ScrapeBottleWord(shop Shop) []Angebot { td_str := e.ChildText("td") matched, err := regexp.MatchString("^[0-9]+([,.][0-9]+)? l$", td_str) if err != nil { - log.Fatal(err) + Fatal(err, "Bottleworld: Volume and ABV Regex failed") } if matched { e.Request.Ctx.Put("volume", td_str) |
