strings.NewReader用法
使用http.Post方法,三个参数,第三个参数body类型io.Reader。
strings.NewReader() 字节
func main() {
cists := []string{"北京","武汉"}
for _, c := range cists {
c_name := fmt.Sprintf("cname=&pid=&keyword=%s&pageIndex=1&pageSize=50",c)
resp,_ :=http.Post(
"http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword",
"application/x-www-form-urlencoded",
strings.NewReader(c_name),
)
body,_ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
resp.Body.Close()
}
}

浙公网安备 33010602011771号