This is a creation in Article, where the information may have evolved or changed.
Go language request, small case list get with post:
Package Main Import ("FMT""Net/http""Io/ioutil""Strings""OS""IO"Func Main () {HttpGet () Content:=httppostparmas () savafile (content)}func HttpGet () {resp,Err: =http.Get("Http://www.baidu.com")if Err!=nil {fmt. Println ("already initialized")} Defer resp. Body.close () body,Err: =ioutil. ReadAll (resp. Body)if Err!=nil {fmt. Println ("Get body from Ioutil")} FMT. Println (string(body)) Fmt. Println ("---------------------------------------------------------------------------------------------------------- -------------------------------")}func Httppostparmas () (contentstring) {client: =&http. client{} Rep,Err: =http. Newrequest ("POST","Http://www.baidu.com", strings. Newreader ("NAME=CJB"))if Err!=nil{FMT. Println ("----HttpRequest-------")} Rep. Header.Set("Content-type","application/x-www-form-urlencoded") Rep. Header.Set("Cookie","Name=anny") RESP,Err: =client. Do(rep) Defer resp. Body.close () body,Err: =ioutil. ReadAll (resp. Body)if Err!=nil{FMT. Println ("----httprequest----Body---")} FMT. Println (string(body)) Returnstring(body)} Func Savafile (contentstring) {var file *os. File varErr Errorvar filenamestring="./temp.html"FileErr=os. Create (filename)if Err!=nil{Panic (Err)} N,Err: =io. WriteString (file,content)if Err!=nil {Panic (Err)} file. Close () fmt. Printf ("Write%d bytes n", n) file. Sync ()}