http获取html文本

package  main

import (
    "net/http"
    "io/ioutil"
    "fmt"
)

func main(){
    resp, err :=http.Get("https://www.zhenai.com/zhenghun")
    if err!=nil{
        panic(err)
    }
    defer resp.Body.Close()

    if resp.StatusCode != http.StatusOK {
        fmt.Printf("Error Status Code: %d", resp.StatusCode)
        return
    }
    all, err :=ioutil.ReadAll(resp.Body)
    if err!=nil {
        panic(err)
    }
    fmt.Printf("%s\n",all)
}

results matching ""

    No results matching ""