Golang net/http.Client.PostForm() function example
package net/http
Golang net/http.Client.PostForm() function usage example
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
)
func main() {
urlData := url.Values{}
urlData.Set("search_query", "macross")
client := &http.Client{}
resp, err := client.PostForm("https://www.youtube.com/results?search_query=", urlData)
if err != nil {
panic(nil)
}
defer resp.Body.Close()
htmlData, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(os.Stdout, string(htmlData))
}
Reference :
Advertisement
Something interesting
Tutorials
+17.1k Golang : Find file size(disk usage) with filepath.Walk
+13.4k Golang : Get constant name from value
+5.2k JavaScript/JQuery : Redirect page examples
+14.2k Golang : Simple word wrap or line breaking example
+8.2k Golang : Metaprogramming example of wrapping a function
+8.2k Swift : Convert (cast) Character to Integer?
+4.9k Python : Find out the variable type and determine the type with simple test
+4.3k Golang : Valued expressions and functions example
+6.8k Golang : Decode XML data from RSS feed
+12k Golang : Detect user location with HTML5 geo-location
+16.4k Golang : Check if a string contains multiple sub-strings in []string?
+4.5k Javascript : Detect when console is activated and do something about it