summaryrefslogtreecommitdiff
path: root/crawler/convert_price.go
diff options
context:
space:
mode:
authorMax2018-02-08 18:26:41 +0100
committerMax2018-02-08 18:26:41 +0100
commitf6904aab20e2d09255fd0adabfd246165ff3cb02 (patch)
treef7ac27cb5dd34443640235a97ce9bde8f2a1816a /crawler/convert_price.go
parentae7ed42df6a55e36c82b88e7c71569951847a68c (diff)
downloadalkobote-f6904aab20e2d09255fd0adabfd246165ff3cb02.tar.gz
Crawler extracts volume, price per litre and abv. (MC Whisky, Rum & Co, Whic)
Diffstat (limited to 'crawler/convert_price.go')
-rw-r--r--crawler/convert_price.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/crawler/convert_price.go b/crawler/convert_price.go
index d9725a0..a76c067 100644
--- a/crawler/convert_price.go
+++ b/crawler/convert_price.go
@@ -2,6 +2,8 @@ package main
import (
"errors"
+ "log"
+ "regexp"
"strconv"
"strings"
)
@@ -28,6 +30,12 @@ func convert_price(price string) (int, error) {
price = strings.TrimSuffix(strings.ToLower(price), "euro")
price = strings.TrimSpace(price)
+ r, err := regexp.Compile(`[0-9]+([.,][0-9]+)?`)
+ if err != nil {
+ return 0, err
+ }
+ price = r.FindString(price)
+
if len(price) < 2 {
price = "00" + price
} else if len(price) < 3 {
@@ -90,6 +98,7 @@ func convert_price(price string) (int, error) {
*/
price_int, err := strconv.Atoi(price)
if err != nil {
+ log.Println(price)
return 0, err
}