summaryrefslogtreecommitdiff
path: root/crawler/shop_whiskysitenl.go
diff options
context:
space:
mode:
Diffstat (limited to 'crawler/shop_whiskysitenl.go')
-rw-r--r--crawler/shop_whiskysitenl.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/crawler/shop_whiskysitenl.go b/crawler/shop_whiskysitenl.go
new file mode 100644
index 0000000..c8b35a2
--- /dev/null
+++ b/crawler/shop_whiskysitenl.go
@@ -0,0 +1,59 @@
+package main
+
+import (
+ "log"
+ "regexp"
+ "strings"
+
+ "github.com/gocolly/colly"
+)
+
+func ScrapeWhiskysitenl(shop Shop) []Angebot {
+ Whiskys := []Angebot{}
+
+ c := colly.NewCollector(
+ colly.AllowedDomains("whiskysite.nl"),
+ colly.AllowedDomains("www.whiskysite.nl"),
+ )
+
+ c.OnHTML(".product-block", func(e *colly.HTMLElement) {
+
+ W := Angebot{}
+
+ whisky_name := e.ChildAttr("img", "alt")
+ whisky_url := e.ChildAttr("a", "href")
+
+ W.Name = whisky_name
+ W.Url = whisky_url
+
+ regular_price := e.ChildText(".price-old")
+ price_discount_noisy := e.ChildText(".product-block-price")
+ r, err := regexp.Compile("[0-9]+(,[0-9]{1,2})")
+ if err != nil {
+ log.Fatal(err)
+ }
+ discounted_price := r.FindString(strings.Trim(strings.TrimPrefix(price_discount_noisy, regular_price), ""))
+
+ W.Original_price, err = sanitize_price(regular_price)
+ if err != nil {
+ //log.Println(W.Name, err)
+ return
+ }
+ W.Discounted_price, err = sanitize_price(discounted_price)
+ if err != nil {
+ //log.Println(W.Name, err)
+ return
+ }
+
+ W.Image_url = e.ChildAttr("img", "src")
+
+ W.Shop = shop.Id
+ W.Spirit_type = "Whisky"
+
+ Whiskys = append(Whiskys, W)
+ })
+
+ c.Visit("https://www.whiskysite.nl/en/specials/?limit=100")
+
+ return Whiskys
+}