summaryrefslogtreecommitdiff
path: root/crawler/shop_whiskyzone.go
diff options
context:
space:
mode:
authorhorus2018-05-14 16:40:03 +0200
committerhorus2018-05-14 16:40:03 +0200
commitd2e65d7a6d51c030ebc87b660bf482ae2ad024f3 (patch)
treefce56a19f25d0118600f38c1c1d94575c3c1f663 /crawler/shop_whiskyzone.go
parent006efbf61b28febfb79e93f6476e0552bbcc08bc (diff)
downloadalkobote-d2e65d7a6d51c030ebc87b660bf482ae2ad024f3.tar.gz
Various fix, e.g. it repairs wrong image urls. (crawler)
Diffstat (limited to 'crawler/shop_whiskyzone.go')
-rw-r--r--crawler/shop_whiskyzone.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/crawler/shop_whiskyzone.go b/crawler/shop_whiskyzone.go
index eae0852..2c1fb99 100644
--- a/crawler/shop_whiskyzone.go
+++ b/crawler/shop_whiskyzone.go
@@ -1,6 +1,7 @@
package main
import (
+ "errors"
"strings"
"github.com/gocolly/colly"
@@ -35,6 +36,7 @@ func (app *App) ScrapeWhiskyzone(shop Shop) []Angebot {
W.Shop = shop.Id
W.Spirit_type = "Whisky"
+ e.Request.Ctx.Put("offer_url", W.Url)
e.Request.Visit(W.Url)
if "sold_out" == e.Request.Ctx.Get("sold_out") {
@@ -93,12 +95,20 @@ func (app *App) ScrapeWhiskyzone(shop Shop) []Angebot {
})
c.OnHTML(".product--buybox", func(e *colly.HTMLElement) {
+ offer_url := e.Request.Ctx.Get("offer_url")
+ Debug(nil, "Visiting: "+e.Request.URL.String()+" with offer_url: "+offer_url)
+
+ if e.Request.URL.String() != offer_url {
+ return
+ }
+
if e.Request.URL.String() == Shop_url {
return
}
// Original & Discounted Price
e.ForEach(".product--price.price--default.price--discount", func(i int, e *colly.HTMLElement) {
+ Debug(errors.New("Discount: "+e.ChildText(".price--content.content--default")), "Whiskyzone: Original:"+e.ChildText(".price--line-through"))
e.Request.Ctx.Put("discounted_price", e.ChildText(".price--content.content--default"))
e.Request.Ctx.Put("original_price", e.ChildText(".price--line-through"))
})