我嘗試用這個代碼解析的頁面:HTTP NewRequest得到意想不到的人物
client := &http.Client{}
profile := getEpiURL(login)
log.Print("Fetch " + profile)
req, err := http.NewRequest("GET", profile, nil)
if err != nil {
log.Fatal(err)
}
req.AddCookie(cookieSessionIntra)
body, _ := httputil.DumpRequestOut(req, true)
以此爲getEpiURL功能:
func getEpiURL(login string) (url string) {
url = "https://********/user/" + login + "/?format=json"
return
}
當我看輸出profile
變好,但在請求中似乎顯然是錯誤的...
2016/11/24 12:53:53取https:// ********/user/le **** in -VI ** RD @ ?è******* /格式= JSON
然後該請求的調試打印我:
GET /用戶/%00升%***** 0O%* 00.%00c***0-%00v%00i%0*a%00r%00d%[email protected]%00e%0 0i%00t%00e%00c%0 *** 0.%0 *** 00/?format = json HTTP/1.1 Host:****** User-Agent:Go-http-client/1.1 Cookie: PHPSESSID = ********* Accept-Encoding:gzip
請注意,您嘗試屏蔽的文字在百分比編碼輸出中很容易看到。 – cnicutar
是的。不是很重要,但下次我會更加關注:/ –