summaryrefslogtreecommitdiff
path: root/crawler/convert_price.go
diff options
context:
space:
mode:
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
}