我想使用搜寻器访问https://bet.hkjc.com/marksix/default.aspx,但是我总是收到超时错误。我通常无法使用邮递员仿真获得返回数据。它只会在浏览器下正常显示。
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
cli := &http.Client{
Transport: tr,
}
cli.Timeout = 10 * time.Second
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Content-Type", "application/json")
//req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
req.Header.Set("Connection", "Keep-Alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36")
req.Header.Add("Referer", "https://bet.hkjc.com/marksix/index.aspx?lang=ch")
resp, err := cli.Do(req)
fmt.Println("err",err)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("doc",string(body))