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
+11.5k Golang : GTK Input dialog box examples
+14.8k Golang : Accurate and reliable decimal calculations
+8k Golang : Number guessing game with user input verification example
+6.6k Golang : Normalize email to prevent multiple signups example
+5.4k Unix/Linux/MacOSx : Get local IP address
+14.9k Golang : Get all local users and print out their home directory, description and group id
+5.1k Python : Delay with time.sleep() function example
+5.2k Golang : If else example and common mistake
+10.2k Golang : Create matrix with Gonum Matrix package example
+8.1k Golang : Implementing class(object-oriented programming style)
+14.3k Golang : Rename directory
+32.3k Golang : Regular Expression for alphanumeric and underscore