diff options
Diffstat (limited to 'crawler/shop_whiskyzone.go')
| -rw-r--r-- | crawler/shop_whiskyzone.go | 10 |
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")) }) |
