From 017b7689536436432ad71293ff9fa11391bde458 Mon Sep 17 00:00:00 2001 From: flygrounder Date: Wed, 12 Jun 2019 09:56:59 +0300 Subject: [PATCH] Fixed SCG search --- cardsinfo/scgprices.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cardsinfo/scgprices.go b/cardsinfo/scgprices.go index d56be58..7193f04 100644 --- a/cardsinfo/scgprices.go +++ b/cardsinfo/scgprices.go @@ -11,7 +11,8 @@ import ( const SCGURL = "http://www.starcitygames.com/results?name=" func GetSCGPrices(name string) ([]CardPrice, error) { - url := getSCGUrl(name) + preprocessedName := preprocessNameForSearch(name) + url := getSCGUrl(preprocessedName) doc, err := htmlquery.LoadURL(url) if err != nil { return nil, err @@ -19,6 +20,10 @@ func GetSCGPrices(name string) ([]CardPrice, error) { return fetchPrices(doc) } +func preprocessNameForSearch(name string) string { + return strings.Replace(name, "|", "", 1) +} + func fetchPrices(doc *html.Node) ([]CardPrice, error) { priceContainers := getPriceContainers(doc) prices := make([]CardPrice, 0)