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.5k How to enable MariaDB/MySQL logs ?
+13.3k Android Studio : Password input and reveal password example
+8.6k Golang : Find duplicate files with filepath.Walk
+7.5k Golang : Convert(cast) io.Reader type to string
+5.2k Python : Convert(cast) string to bytes example
+29.2k Golang : JQuery AJAX post data to server and send data back to client example
+5.2k Unix/Linux/MacOSx : How to remove an environment variable ?
+6.4k Golang : Totalize or add-up an array or slice example
+6.3k PHP : Proper way to get UTF-8 character or string length
+15.6k Golang : Get digits from integer before and after given position example
+18.5k Golang : Implement getters and setters