我想下載幻想足球數據以在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 回答
- 0 關注
- 298 瀏覽
添加回答
舉報
0/150
提交
取消
