我想下载幻想足球数据以在Go中进行分析,但是当我尝试从此api页面下载时,即使代码适用于其他网站(例如此api页面),我仍返回一个空响应最小复制,输出一个空数组。package mainimport ( "fmt" "io/ioutil" "net/http" "time")const AllPlayerData = "https://fantasy.premierleague.com/drf/bootstrap-static"func main() { downloadAllData()}func downloadAllData() { client := &http.Client{ Timeout: 20 * time.Second, } response, err := client.Get(AllPlayerData) if err != nil { fmt.Println("Unable to download player data.") return } body, err := ioutil.ReadAll(response.Body) if err != nil { fmt.Println("Failed to read response") return } defer response.Body.Close() fmt.Println(body)}相同的网页在Python中可以正常下载:import requestsurl = "https://fantasy.premierleague.com/drf/bootstrap-static"r = requests.get(url)print(r.content)我认为这与例如Ajax调用无关,因为在Chrome浏览器中查看网络请求不会超出页面加载本身
1 回答
- 1 回答
- 0 关注
- 263 浏览
添加回答
举报
0/150
提交
取消