diff options
Diffstat (limited to 'crawler/shop_whiskyzone.go')
| -rw-r--r-- | crawler/shop_whiskyzone.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/crawler/shop_whiskyzone.go b/crawler/shop_whiskyzone.go index 5809b7e..c07c14f 100644 --- a/crawler/shop_whiskyzone.go +++ b/crawler/shop_whiskyzone.go @@ -1,7 +1,6 @@ package main import ( - "log" "strings" "github.com/gocolly/colly" @@ -38,17 +37,20 @@ func ScrapeWhiskyzone(shop Shop) []Angebot { e.Request.Visit(W.Url) + if "sold_out" == e.Request.Ctx.Get("sold_out") { + PrintlnOffer(W, "Whiskyzone: Sold out") + return + } + var err error W.Discounted_price, err = convert_price(e.Request.Ctx.Get("discounted_price")) if err != nil { - log.Println("Discounted_price failed") - log.Fatal(err) + Fatal(err, "Whiskyzone: Convert discounted price failed") } W.Original_price, err = convert_price(e.Request.Ctx.Get("original_price")) if err != nil { - log.Println("Original_price failed") - log.Fatal(err) + Fatal(err, "Whiskyzone: Convert original price failed") } W.Volume = get_volume(e) @@ -110,6 +112,16 @@ func ScrapeWhiskyzone(shop Shop) []Angebot { e.Request.Ctx.Put("website", string(e.Response.Body)) }) + // Product not found + c.OnHTML(".detail-error--headline", func(e *colly.HTMLElement) { + if e.Request.URL.String() == Shop_url { + return + } + + e.Request.Ctx.Put("sold_out", "sold_out") + + }) + c.Visit(Shop_url) return Whiskys |
