diff options
Diffstat (limited to 'crawler/shop_bottleworld.go')
| -rw-r--r-- | crawler/shop_bottleworld.go | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/crawler/shop_bottleworld.go b/crawler/shop_bottleworld.go index db45791..720f2c8 100644 --- a/crawler/shop_bottleworld.go +++ b/crawler/shop_bottleworld.go @@ -8,7 +8,7 @@ import ( "github.com/gocolly/colly" ) -func ScrapeBottleWord(shop Shop) []Angebot { +func (app *App) ScrapeBottleWord(shop Shop) []Angebot { Shop_url := "https://www.bottleworld.de/aktuelle-sonderpreise/show/all" Whiskys := []Angebot{} @@ -32,13 +32,19 @@ 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 { - Fatal(err, "Bottleworld: Converting original price failed") + W.error_msg = err.Error() + W.error_ctx = e.ChildText(".price") + WarnOffer(W, "Bottleworld: Converting original price failed") + return } }) e.ForEach(".special-price", func(i int, e *colly.HTMLElement) { W.Discounted_price, err = convert_price(e.ChildText(".price")) if err != nil { - Fatal(err, "Bottleworld: Converting discounted price failed") + W.error_msg = err.Error() + W.error_ctx = e.ChildText(".price") + WarnOffer(W, "Bottleworld: Converting discounted price failed") + return } }) }) @@ -46,7 +52,10 @@ 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 { - Fatal(err, "Bottleworld: Sanitizing base price failed") + W.error_msg = err.Error() + W.error_ctx = price_per_litre_noisy + WarnOffer(W, "Bottleworld: Sanitizing base price failed") + return } W.Base_price = price_per_litre @@ -56,14 +65,19 @@ func ScrapeBottleWord(shop Shop) []Angebot { W.Shop = shop.Id - W.Volume = get_volume(e) + var ctx string + W.Volume, ctx = get_volume(e) if W.Volume == 0 { - DebugOffer(W, "Bottleworld: Volume is zero") + W.error_msg = "Bottleworld: Volume is zero" + W.error_ctx = ctx + WarnOffer(W, "Bottleworld: Volume is zero") return } - W.Abv = get_abv(e) + W.Abv, ctx = get_abv(e) if W.Abv == 0 { - DebugOffer(W, "Bottleworld: Abv is zero") + W.error_msg = "Bottleworld: Abv is zero" + W.error_ctx = ctx + WarnOffer(W, "Bottleworld: Abv is zero") return } |
