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
+20.5k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+6.2k Golang : How to handle file size larger than available memory panic issue
+5.5k Golang : Derive cryptographic key from passwords with Argon2
+18.1k Golang : Measure http.Get() execution time
+10.3k Golang : Generate DSA private, public key and PEM files example
+4.5k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)
+5.9k Golang : A simple forex opportunities scanner
+6.9k Golang : Multiplexer with net/http and map
+20.8k Golang : Read directory content with filepath.Walk()
+25.4k Golang : How to check if a connection to database is still alive ?
+3.9k Javascript : How to get width and height of a div?