summaryrefslogtreecommitdiff
path: root/rumundco.go
diff options
context:
space:
mode:
authorhorus_arch2018-02-04 20:54:58 +0100
committerhorus_arch2018-02-04 20:54:58 +0100
commit4f7a9316da8e19fa9466ee377148c7d07bf39fd9 (patch)
tree7c4fb5b35ea107d7379b4c7a601aa9a7d9d184d5 /rumundco.go
parentfe12a1d41d74ac55dc3c1b27821375541ee5f2b2 (diff)
downloadalkobote-4f7a9316da8e19fa9466ee377148c7d07bf39fd9.tar.gz
Data from all shops are now saved in a data structure.
Diffstat (limited to 'rumundco.go')
-rw-r--r--rumundco.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/rumundco.go b/rumundco.go
index d941e73..3c1fb4e 100644
--- a/rumundco.go
+++ b/rumundco.go
@@ -1,7 +1,6 @@
package main
import (
- "fmt"
"log"
"regexp"
"strings"
@@ -10,13 +9,17 @@ import (
"github.com/gocolly/colly"
)
-func ScrapeRumundCo() {
+func ScrapeRumundCo() []Angebot {
+ Whiskys := []Angebot{}
+
c := colly.NewCollector(
colly.AllowedDomains("rumundco.de"),
colly.AllowedDomains("www.rumundco.de"),
)
c.OnHTML(".product-teaser", func(e *colly.HTMLElement) {
+ W := Angebot{}
+
whisky_name := strings.TrimPrefix(e.ChildAttr("img", "alt"), "Restposten: ")
whisky_url := "https://www.rumundco.de/" + e.ChildAttr("a", "href")
@@ -28,21 +31,32 @@ func ScrapeRumundCo() {
return
}
- log.Println(whisky_name)
- log.Println(whisky_url)
+ W.Name = whisky_name
+ W.Url = whisky_url
e.ForEach(".price_wrapper", func(i int, e *colly.HTMLElement) {
regular_price := e.ChildText("del.value")
if "" == regular_price {
return
}
- log.Println(regular_price)
- log.Println(e.ChildText(".price-value"))
+ W.Original_price, err = sanitize_price(regular_price)
+ if err != nil {
+ log.Fatal(err)
+ }
+ W.Discounted_price, err = sanitize_price(e.ChildText(".price-value"))
+ if err != nil {
+ log.Fatal(err)
+ }
})
- log.Println("https://www.rumundco.de/" + e.ChildAttr("img", "src"))
+ W.Image_url = "https://www.rumundco.de/" + e.ChildAttr("img", "src")
+
+ W.Shop = "Rum & Co"
+ W.Spirit_type = "Whisky"
- fmt.Println("")
+ Whiskys = append(Whiskys, W)
})
c.Visit("https://www.rumundco.de/navi.php?q=4&kf=29&kk-suesse-von=0&kk-suesse-bis=100&kk-milde-von=0&kk-milde-bis=100&kk-wuerze-von=0&kk-wuerze-bis=100&kk-frucht-von=0&kk-frucht-bis=100&kk-torf-von=0&kk-torf-bis=100&hf=0&af=90&Sortierung=11&a=350")
+
+ return Whiskys
}