package main import ( "net/http" "io/ioutil" "fmt" // "time" ) func main(){ var website string = "http://www.future.org.cn" if resp,err := http.Get(website); err == nil{ defer resp.Body.Close() if body, err := ioutil.ReadAll(resp.Body); err == nil { fmt.Println("HTML content:", string(body)); }else{ fmt.Println("Cannot read from connected http server:", err); } }else{ fmt.Println("Cannot connect the server:", err); } }
有疑问加站长微信联系(非本文作者)