我正在向服务器发送请求,但它正在返回一个网页。有没有办法获取网页的网址?
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
req, err := http.NewRequest("GET", "https://www.google.com", nil)
if err != nil {
panic(err)
}
client := new(http.Client)
response, err := client.Do(req)
if err != nil {
panic(err)
}
fmt.Println(ioutil.ReadAll(response.Body))
}
Helenr
相关分类