Post
ref https://ithelp.ithome.com.tw/articles/10159383
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| func get() {
resp, err := http.Get("https://123/456.php?q=789")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
html := string(body)
doc := soup.HTMLParse(html)
}
func post() {
resp, err := http.PostForm("https://123", url.Values{"SN": {word}})
if err != nil {
// handle error
}
resp.Header.Set("Content-Type", "application/x-www-form-urlencoded;application/json; charset=utf-8")
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
html := string(body)
doc := soup.HTMLParse(html)
}
|