summaryrefslogtreecommitdiff
path: root/crawler/shop_whiskyde.go
diff options
context:
space:
mode:
Diffstat (limited to 'crawler/shop_whiskyde.go')
-rw-r--r--crawler/shop_whiskyde.go38
1 files changed, 30 insertions, 8 deletions
diff --git a/crawler/shop_whiskyde.go b/crawler/shop_whiskyde.go
index f13190b..ffbbe08 100644
--- a/crawler/shop_whiskyde.go
+++ b/crawler/shop_whiskyde.go
@@ -6,7 +6,7 @@ import (
"github.com/gocolly/colly"
)
-func ScrapeWhiskyde(shop Shop) []Angebot {
+func (app *App) ScrapeWhiskyde(shop Shop) []Angebot {
Shop_url := "https://www.whisky.de/shop/Aktuell/Sonderangebote/"
Whiskys := []Angebot{}
@@ -33,13 +33,19 @@ func ScrapeWhiskyde(shop Shop) []Angebot {
e.ForEach(".article-price-original", func(i int, e *colly.HTMLElement) {
W.Original_price, err = convert_price(e.ChildText("del"))
if err != nil {
- Fatal(err, "Whisky.de: Converting original price failed")
+ W.error_msg = err.Error()
+ W.error_ctx = e.ChildText("del")
+ WarnOffer(W, "Whisky.de: Converting original price failed")
+ return
}
})
e.ForEach(".article-price", func(i int, e *colly.HTMLElement) {
W.Discounted_price, err = convert_price(e.ChildText(".article-price-default"))
if err != nil {
- Fatal(err, "Whisky.de: Converting discounted price failed")
+ W.error_msg = err.Error()
+ W.error_ctx = e.ChildText(".article-price-default")
+ WarnOffer(W, "Whisky.de: Converting discounted price failed")
+ return
}
})
@@ -54,25 +60,38 @@ func ScrapeWhiskyde(shop Shop) []Angebot {
text_noisy := e.ChildText(".article-amount")
if !strings.Contains(text_noisy, "Liter") {
+ W.error_ctx = text_noisy
+ W.error_msg = "Whisky.de: String 'Liter' not found."
+ WarnOffer(W, "Whisky.de: String 'Liter' not found.")
return
}
abv_noisy := strings.TrimSpace(strings.SplitAfter(text_noisy, "Liter")[1])
W.Volume, err = extract_volume(text_noisy)
if err != nil {
- Fatal(err, "Whisky.de: Extracting volume failed")
+ W.error_msg = err.Error()
+ W.error_ctx = text_noisy
+ WarnOffer(W, "Whisky.de: Extracting volume failed")
+ return
}
W.Abv, err = extract_abv(abv_noisy)
if err != nil {
- Fatal(err, "Whisky.de: Extracting abv failed")
+ W.error_msg = err.Error()
+ W.error_ctx = abv_noisy
+ WarnOffer(W, "Whisky.de: Extracting abv failed")
+ return
}
if W.Volume == 0 {
- DebugOffer(W, "Whisky.de: Volume is zero")
+ W.error_msg = "Whisky.de: Volume is zero"
+ W.error_ctx = text_noisy
+ WarnOffer(W, "Whisky.de: Volume is zero")
return
}
if W.Abv == 0 {
- DebugOffer(W, "Whisky.de: Abv is zero")
+ W.error_msg = "Whisky.de: Abv is zero"
+ W.error_ctx = abv_noisy
+ WarnOffer(W, "Whisky.de: Abv is zero")
return
}
@@ -81,7 +100,10 @@ func ScrapeWhiskyde(shop Shop) []Angebot {
W.Base_price, err = convert_price(e.ChildText(".article-unitprice-default"))
if err != nil {
- Fatal(err, "Whisky.de: Converting base price failed")
+ W.error_msg = err.Error()
+ W.error_ctx = e.ChildText(".article-unitprice-default")
+ WarnOffer(W, "Whisky.de: Converting base price failed")
+ return
}
e.Request.Visit(W.Url)