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);
}
}
GO语言:Get拉取网页
最新推荐文章于 2023-09-14 19:00:10 发布