summaryrefslogtreecommitdiff
path: root/crawler/shop_whiskyzone.go
diff options
context:
space:
mode:
authorhorus2018-02-16 16:57:10 +0100
committerhorus2018-02-16 16:57:39 +0100
commited6ab4da59f80bf9fa2cbf15da5c9167dff44ea4 (patch)
tree1038ab5d9b2a0b9bde5ee021624fa87422b705f8 /crawler/shop_whiskyzone.go
parentb131ce750740ddb9c47515727327c06aa0d22aad (diff)
downloadalkobote-ed6ab4da59f80bf9fa2cbf15da5c9167dff44ea4.tar.gz
Adds structured logging. (crawler)
Diffstat (limited to 'crawler/shop_whiskyzone.go')
-rw-r--r--crawler/shop_whiskyzone.go22
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