zoukankan      html  css  js  c++  java
  • golang每隔10秒访问URL

    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.html
     
     

    golang sleep

    https://blog.csdn.net/lanyang123456/article/details/78158457

     
     
  • 相关阅读:
    POJ——T2186 Popular Cows || 洛谷——P2341 [HAOI2006]受欢迎的牛
    Tarjan缩点【模板】
    shell(1):网络配置、BATH环境和通配符
    STL
    J
    H
    G
    模板整理(二)
    B
    0-1背包问题
  • 原文地址:https://www.cnblogs.com/pangchunyu/p/11388730.html
Copyright © 2011-2022 走看看