Fixed SCG search

This commit is contained in:
flygrounder 2019-06-12 09:56:59 +03:00
parent 98a8040246
commit 017b768953

View file

@ -11,7 +11,8 @@ import (
const SCGURL = "http://www.starcitygames.com/results?name=" const SCGURL = "http://www.starcitygames.com/results?name="
func GetSCGPrices(name string) ([]CardPrice, error) { func GetSCGPrices(name string) ([]CardPrice, error) {
url := getSCGUrl(name) preprocessedName := preprocessNameForSearch(name)
url := getSCGUrl(preprocessedName)
doc, err := htmlquery.LoadURL(url) doc, err := htmlquery.LoadURL(url)
if err != nil { if err != nil {
return nil, err return nil, err
@ -19,6 +20,10 @@ func GetSCGPrices(name string) ([]CardPrice, error) {
return fetchPrices(doc) return fetchPrices(doc)
} }
func preprocessNameForSearch(name string) string {
return strings.Replace(name, "|", "", 1)
}
func fetchPrices(doc *html.Node) ([]CardPrice, error) { func fetchPrices(doc *html.Node) ([]CardPrice, error) {
priceContainers := getPriceContainers(doc) priceContainers := getPriceContainers(doc)
prices := make([]CardPrice, 0) prices := make([]CardPrice, 0)