summaryrefslogtreecommitdiff
path: root/whiskyzone.go
diff options
context:
space:
mode:
authorMax2018-02-01 16:13:56 +0100
committerMax2018-02-01 16:13:56 +0100
commit35882837a2821749f3a2b1dfa23f19c4168004d3 (patch)
tree5d6ac5078aebac93db47e507f564842d120bd1a3 /whiskyzone.go
parenta5bda60647639e787a777446dce693ac330fe940 (diff)
downloadalkobote-35882837a2821749f3a2b1dfa23f19c4168004d3.tar.gz
Crawled the first seven shops.
Diffstat (limited to 'whiskyzone.go')
-rw-r--r--whiskyzone.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/whiskyzone.go b/whiskyzone.go
new file mode 100644
index 0000000..10b996b
--- /dev/null
+++ b/whiskyzone.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "regexp"
+
+ "github.com/gocolly/colly"
+)
+
+func ScrapeWhiskyzone() {
+ c := colly.NewCollector(
+ colly.AllowedDomains("whiskyzone.de"),
+ colly.AllowedDomains("www.whiskyzone.de"),
+ )
+
+ c.OnHTML(".product--info", func(e *colly.HTMLElement) {
+
+ whisky_name := e.ChildAttr("a", "title")
+ whisky_url := e.ChildAttr("a", "href")
+ log.Println(whisky_name)
+ log.Println(whisky_url)
+ price_discount_noisy := e.ChildText(".price--default")
+ price_regular_noisy := e.ChildText(".price--discount")
+
+ r, err := regexp.Compile("[0-9]+(,[0-9]{1,2})")
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Println(r.FindString(price_discount_noisy) + "€")
+ log.Println(r.FindString(price_regular_noisy) + "€")
+
+ e.ForEach(".image--media", func(i int, e *colly.HTMLElement) {
+ log.Println(e.ChildAttr("img", "src"))
+ })
+
+ fmt.Println("")
+ })
+
+ c.Visit("https://www.whiskyzone.de/widgets/emotion/index/emotionId/248/controllerName/listing")
+}
+
+func main() {
+ ScrapeWhiskyzone()
+}