1st
This commit is contained in:
31
tennis_api.go
Normal file
31
tennis_api.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package flashscore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
webspider "gordenko.dev/dima/spider"
|
||||
)
|
||||
|
||||
// Метод, который вызывается без объекта
|
||||
|
||||
func LoadTennisMatchStat(matchID string) (stat TennisMatchStat, err error) {
|
||||
spider, err := webspider.NewSpider(nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
url := fmt.Sprintf(tennisMatchStatURLPattern, matchID)
|
||||
|
||||
buf, err := spider.Get(url, map[string]string{
|
||||
"x-requested-with": "XMLHttpRequest",
|
||||
"x-fsign": feedSign,
|
||||
"x-geoip": "1",
|
||||
"referer": "https://d.flashscore.com/x/feed/proxy-fetch",
|
||||
})
|
||||
if err != nil {
|
||||
err = fmt.Errorf("LoadTennisMatchStat: %s; url=%s", err, url)
|
||||
return
|
||||
}
|
||||
|
||||
return parseTennisMatchStat(string(buf))
|
||||
}
|
||||
Reference in New Issue
Block a user