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
+13.9k Golang : Check if a file exist or not
+18.3k Golang : Iterating Elements Over A List
+15.4k Golang : Get checkbox or extract multipart form data value example
+10.4k Golang : Flip coin example
+6.4k Golang : Warp text string by number of characters or runes example
+4.8k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+9.9k Golang : Edge detection with Sobel method
+7.5k Gogland : Where to put source code files in package directory for rookie
+15.7k Golang : Update database with GORM example
+9.2k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+12.4k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+11.4k Golang : Surveillance with web camera and OpenCV