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
+15.3k Golang : How to check if IP address is in range
+11.8k Golang : How to detect a server/machine network interface capabilities?
+22.2k Golang : Match strings by wildcard patterns with filepath.Match() function
+30.9k Golang : Interpolating or substituting variables in string examples
+12.8k Golang : Add ASCII art to command line application launching process
+4.8k PHP : Extract part of a string starting from the middle
+25.1k Golang : Create PDF file from HTML file
+16k Golang : Read large file with bufio.Scanner cause token too long error
+18.9k Golang : Read input from console line
+17.7k Golang : Upload/Receive file progress indicator
+5.3k Golang : Convert lines of string into list for delete and insert operation