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
+6.5k CodeIgniter : form input set_value cause " to become & quot
+23k Golang : Gorilla mux routing example
+5.7k Swift : Get substring with rangeOfString() function example
+17k Golang : Read integer from file into array
+12.8k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+5.9k Golang : Launching your executable inside a console under Linux
+8.8k Golang : Combine slices but preserve order example
+10.8k Android Studio : Simple input textbox and intercept key example
+16.1k Golang : Generate universally unique identifier(UUID) example
+12k Golang : GTK Input dialog box examples
+29.7k Golang : Saving(serializing) and reading file with GOB
+22.2k Golang : Join arrays or slices example