summaryrefslogtreecommitdiff
path: root/bottleworld.go
diff options
context:
space:
mode:
Diffstat (limited to 'bottleworld.go')
-rw-r--r--bottleworld.go33
1 files changed, 25 insertions, 8 deletions
diff --git a/bottleworld.go b/bottleworld.go
index edba866..55ee47c 100644
--- a/bottleworld.go
+++ b/bottleworld.go
@@ -1,7 +1,6 @@
package main
import (
- "fmt"
"log"
"regexp"
// "strings"
@@ -10,13 +9,17 @@ import (
"github.com/gocolly/colly"
)
-func ScrapeBottleWord() {
+func ScrapeBottleWord() []Angebot {
+ Whiskys := []Angebot{}
+
c := colly.NewCollector(
colly.AllowedDomains("bottleworld.de"),
colly.AllowedDomains("www.bottleworld.de"),
)
c.OnHTML("li.item", func(e *colly.HTMLElement) {
+ W := Angebot{}
+
whisky_name := e.ChildText("h2 > a")
matched, err := regexp.MatchString("Whiske?y", whisky_name)
@@ -24,25 +27,39 @@ func ScrapeBottleWord() {
log.Fatal(err)
}
if !matched {
+ //W.Spirit_type = "Anderes"
return
+ } else {
+ W.Spirit_type = "Whisky"
}
whisky_url := e.ChildAttr("a", "href")
- log.Println(whisky_name)
- log.Println(whisky_url)
+ W.Name = whisky_name
+ W.Url = whisky_url
e.ForEach(".price-box", func(i int, e *colly.HTMLElement) {
e.ForEach(".old-price", func(i int, e *colly.HTMLElement) {
- log.Println(e.ChildText(".price"))
+ W.Original_price, err = sanitize_price(e.ChildText(".price"))
+ if err != nil {
+ log.Fatal(err)
+ }
})
e.ForEach(".special-price", func(i int, e *colly.HTMLElement) {
- log.Println(e.ChildText(".price"))
+ W.Discounted_price, err = sanitize_price(e.ChildText(".price"))
+ if err != nil {
+ log.Fatal(err)
+ }
})
})
- log.Println(e.ChildAttr("img", "src"))
+ W.Image_url = e.ChildAttr("img", "src")
- fmt.Println("")
+ W.Shop = "bottleworld.de"
+ W.Spirit_type = "Whisky"
+
+ Whiskys = append(Whiskys, W)
})
c.Visit("https://www.bottleworld.de/aktuelle-sonderpreise/show/all")
+
+ return Whiskys
}