summaryrefslogtreecommitdiff
path: root/crawler/shop_bottleworld.go
diff options
context:
space:
mode:
authorMax2018-02-08 18:26:41 +0100
committerMax2018-02-08 18:26:41 +0100
commitf6904aab20e2d09255fd0adabfd246165ff3cb02 (patch)
treef7ac27cb5dd34443640235a97ce9bde8f2a1816a /crawler/shop_bottleworld.go
parentae7ed42df6a55e36c82b88e7c71569951847a68c (diff)
downloadalkobote-f6904aab20e2d09255fd0adabfd246165ff3cb02.tar.gz
Crawler extracts volume, price per litre and abv. (MC Whisky, Rum & Co, Whic)
Diffstat (limited to 'crawler/shop_bottleworld.go')
-rw-r--r--crawler/shop_bottleworld.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/crawler/shop_bottleworld.go b/crawler/shop_bottleworld.go
index a3eae35..fdf1cd8 100644
--- a/crawler/shop_bottleworld.go
+++ b/crawler/shop_bottleworld.go
@@ -52,11 +52,11 @@ func ScrapeBottleWord(shop Shop) []Angebot {
})
price_per_litre_noisy := e.ChildText(".price-per-liter")
- price_per_litre, err := sanitize_price_per(price_per_litre_noisy)
+ price_per_litre, err := sanitize_base_price(price_per_litre_noisy)
if err != nil {
log.Fatal(err)
}
- W.Price_per_litre = price_per_litre
+ W.Base_price = price_per_litre
W.Image_url = e.ChildAttr("img", "src")
@@ -64,17 +64,8 @@ func ScrapeBottleWord(shop Shop) []Angebot {
W.Shop = shop.Id
- volume_noisy := e.Request.Ctx.Get("volume")
- W.Volume, err = extract_volume(volume_noisy)
- if err != nil {
- log.Fatal(err)
- }
-
- abv_noisy := e.Request.Ctx.Get("abv")
- W.Abv, err = extract_abv(abv_noisy)
- if err != nil {
- log.Fatal(err)
- }
+ W.Volume = get_volume(e)
+ W.Abv = get_abv(e)
Whiskys = append(Whiskys, W)
})
@@ -82,7 +73,7 @@ func ScrapeBottleWord(shop Shop) []Angebot {
c.OnHTML("#product-attribute-specs-table", func(e *colly.HTMLElement) {
e.ForEach("tr", func(i int, e *colly.HTMLElement) {
td_str := e.ChildText("td")
- matched, err := regexp.MatchString("[0-9]+([,.][0-9]+)? l$", td_str)
+ matched, err := regexp.MatchString("^[0-9]+([,.][0-9]+)? l$", td_str)
if err != nil {
log.Fatal(err)
}