summaryrefslogtreecommitdiff
path: root/whiskysitenl.go
diff options
context:
space:
mode:
authorMax2018-02-06 00:35:39 +0100
committerMax2018-02-06 00:35:39 +0100
commit71950479fbd6088f249e5fda3b180f294d1d745d (patch)
tree06f360a7e02b7e0011bda815fa102ec54ae8d0ec /whiskysitenl.go
parent13a807854bf4d0258723ec3152b217ed4cf8e051 (diff)
downloadalkobote-71950479fbd6088f249e5fda3b180f294d1d745d.tar.gz
Moves crawler to designated directory.
Diffstat (limited to 'whiskysitenl.go')
-rw-r--r--whiskysitenl.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/whiskysitenl.go b/whiskysitenl.go
deleted file mode 100644
index c8b35a2..0000000
--- a/whiskysitenl.go
+++ /dev/null
@@ -1,59 +0,0 @@
-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
-}