📌  相关文章
📜  golang http set user agent header - Go 编程语言代码示例

📅  最后修改于: 2022-03-11 14:45:02.668000             🧑  作者: Mango

代码示例1
import "net/http"

    req, err := http.NewRequest("GET", "http://httpbin.org/user-agent", nil)
    if err != nil {
        log.Fatalln(err)
    }

    req.Header.Set("User-Agent", "Golang_Spider_Bot/3.0")
    
//afetr prepear the request we should submit to http client to perform it
    
    client := &http.Client{}
    resp, err := client.Do(req)
        if err != nil {
                log.Fatalln(err)
        }