Unexported unnecessary members

This commit is contained in:
Artyom Belousov 2021-02-07 15:58:50 +03:00
parent 4da8e94bcc
commit d8a295be75
14 changed files with 134 additions and 115 deletions

View file

@ -10,8 +10,8 @@ import (
const scgDomain = "https://starcitygames.com"
const scgSearchUrlTemplate = "https://starcitygames.hawksearch.com/sites/starcitygames/?search_query="
func (f *Fetcher) GetPrices(name string) ([]CardPrice, error) {
prices, err := GetPricesScg(name)
func (f *Fetcher) getPrices(name string) ([]scgCardPrice, error) {
prices, err := getPricesScg(name)
if err != nil {
return nil, err
}
@ -21,7 +21,7 @@ func (f *Fetcher) GetPrices(name string) ([]CardPrice, error) {
return prices, nil
}
func GetPricesScg(name string) ([]CardPrice, error) {
func getPricesScg(name string) ([]scgCardPrice, error) {
escapedName := url.QueryEscape(name)
searchUrl := scgSearchUrlTemplate + escapedName
node, err := htmlquery.LoadURL(searchUrl)
@ -29,23 +29,23 @@ func GetPricesScg(name string) ([]CardPrice, error) {
return nil, errors.Wrap(err, "cannot load url")
}
blocks := htmlquery.Find(node, "//div[@class=\"hawk-results-item\"]")
var results []CardPrice
var results []scgCardPrice
for _, block := range blocks {
price := &ScgCardPrice{}
price := scgCardPrice{}
linkNode := htmlquery.FindOne(block, "//h2/a")
for _, attr := range linkNode.Attr {
if attr.Key == "href" {
price.Link = scgDomain + attr.Val
price.link = scgDomain + attr.Val
break
}
}
editionNode := htmlquery.FindOne(block, "//p[@class=\"hawk-results-item__category\"]/a")
if editionNode.FirstChild != nil {
price.Edition = editionNode.FirstChild.Data
price.edition = editionNode.FirstChild.Data
}
priceNode := htmlquery.FindOne(block, "//span[@class='hawk-old-price']|//div[contains(concat(' ',normalize-space(@class),' '),' hawk-results-item__options-table-cell--price ')]")
if priceNode.FirstChild != nil {
price.Price = priceNode.FirstChild.Data
price.price = priceNode.FirstChild.Data
}
results = append(results, price)
}