Skip to content

Commit

Permalink
Update scrape rules following site layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
j-vizcaino committed May 8, 2017
1 parent a6aeeea commit be44288
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions auvieux-scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"regexp"
"strconv"
"strings"

"github.com/PuerkitoBio/goquery"
)
Expand All @@ -23,8 +24,8 @@ type product struct {

func convertPrice(pstr string) (float64, error) {
// Remove trailing ' €'
re := regexp.MustCompile(`^(\d+),(\d+).*$`)
s := re.ReplaceAllString(pstr, "$1.$2")
re := regexp.MustCompile(`^(\d+)(\d+)?.*$`)
s := re.ReplaceAllString(strings.TrimSpace(pstr), "$1.$2")
return strconv.ParseFloat(s, 32)
}

Expand All @@ -35,8 +36,8 @@ func scrapeProduct(id string) (*product, error) {
return nil, err
}

name := doc.Find(".product-name > a").First().Text()
priceStr := doc.Find(".regular-price .price").First().Text()
name := doc.Find("span.product-list-name").First().Text()
priceStr := doc.Find("span.price-content-container > span.orangeColor").First().Text()

price, err := convertPrice(priceStr)
if err != nil {
Expand Down

0 comments on commit be44288

Please sign in to comment.