diff options
Diffstat (limited to 'crawler/shop_whiskyworld.go')
| -rw-r--r-- | crawler/shop_whiskyworld.go | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/crawler/shop_whiskyworld.go b/crawler/shop_whiskyworld.go index 5235d3c..def22c6 100644 --- a/crawler/shop_whiskyworld.go +++ b/crawler/shop_whiskyworld.go @@ -6,7 +6,7 @@ import ( "github.com/gocolly/colly" ) -func ScrapeWhiskyworld(shop Shop) []Angebot { +func (app *App) ScrapeWhiskyworld(shop Shop) []Angebot { Shop_urls := []string{"https://www.whiskyworld.de/themen/sonderangebote?ft=%257B%2522produkt_kategorie%2522:%2522Blended%2BMalt%2522%257D", "https://www.whiskyworld.de/themen/sonderangebote?ft=%257B%2522produkt_kategorie%2522:%2522Blended%2BWhiskies%2522%257D", @@ -42,13 +42,17 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { W.Original_price, err = convert_price(regular_price) if err != nil { - Fatal(err, "Whiskyworld: Converting original price failed") + W.error_msg = err.Error() + W.error_ctx = regular_price + WarnOffer(W, "Whiskyworld: Converting original price failed") return } W.Discounted_price, err = convert_price(e.ChildText(".uvp")) if err != nil { - Fatal(err, "Whiskyworld: Converting discounted price failed") + W.error_msg = err.Error() + W.error_ctx = e.ChildText(".uvp") + WarnOffer(W, "Whiskyworld: Converting discounted price failed") return } @@ -56,13 +60,31 @@ func ScrapeWhiskyworld(shop Shop) []Angebot { text_noisy := e.ChildText(".item-inh") W.Volume, err = extract_volume(text_noisy) if err != nil { - Fatal(err, "Whiskyworld: Extracting volume failed") + W.error_msg = err.Error() + W.error_ctx = text_noisy + WarnOffer(W, "Whiskyworld: Extracting volume failed") + return + } + if W.Volume == 0 { + W.error_msg = "Whiskyworld: Volume is zero" + W.error_ctx = text_noisy + WarnOffer(W, "Whiskyworld: Volume is zero") + return } 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 { - Fatal(err, "Whiskyworld: Extracting abv failed") + W.error_msg = err.Error() + W.error_ctx = abv_noisy + WarnOffer(W, "Whiskyworld: Extracting abv failed") + return + } + if W.Abv == 0 { + W.error_msg = "Whiskyworld: Abv is zero" + W.error_ctx = abv_noisy + WarnOffer(W, "Whiskyworld: Abv is zero") + return } }) @@ -72,7 +94,10 @@ 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 { - Fatal(err, "Whiskyworld: Sanitizing base price failed") + W.error_msg = err.Error() + W.error_ctx = base_price_noisy + WarnOffer(W, "Whiskyworld: Sanitizing base price failed") + return } } @@ -83,15 +108,6 @@ 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") |
