package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
func main() {
for i := 1;i< 300;i++{
fmt.Printf("第%d次执行
",i)
getUrl();
}
}
func getUrl(){
url := "https://www.xxx.com/api/xxx"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
time.Sleep(time.Duration(5)*time.Second)
fmt.Println("
")
}
----------------------
参考:
golang post和get发送请求
http://www.361way.com/golang-post-get/5861.htmlgolang sleep
https://blog.csdn.net/lanyang123456/article/details/78158457