什麼,辛辛苦苦寫的文章訪問量這麼低?沒關係我自己來

package main

import (
	"fmt"
	"math/rand"
	"net/http"
	"sync"
	"time"
)

var count = 0

func Get()  {
	count++
	if count >= 20 {
		time.Sleep(time.Minute*20)
		count = 0
	}
	fmt.Println("1")
	urls := []string{
		"https://blog.csdn.net/qq_43186092/article/details/104827416",
		"https://blog.csdn.net/qq_43186092/article/details/104811575",
		"https://blog.csdn.net/qq_43186092/article/details/104781888",
		"https://blog.csdn.net/qq_43186092/article/details/104776107",
		"https://blog.csdn.net/qq_43186092/article/details/104769376",
		"https://blog.csdn.net/qq_43186092/article/details/104760963",
		"https://blog.csdn.net/qq_43186092/article/details/104757626",
		"https://blog.csdn.net/qq_43186092/article/details/104450590",
		"https://blog.csdn.net/qq_43186092/article/details/104448453",
		"https://blog.csdn.net/qq_43186092/article/details/104376860",
	}
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	url := urls[r.Intn(len(urls))]
	req,err := http.NewRequest("GET",url,nil)
	if err != nil {
		return
	}
	req.Header.Add("User-Agent",`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36`)
	req.Header.Add("Accept",`text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9`)
	req.Header.Add("Accept-Encoding",`gzip, deflate, br`)
	req.Header.Add(`Accept-Charset`,`ISO-8859-1,utf-8;q=0.7,*;q=0.3`)
	req.Header.Add("Referer",`https://www.csdn.net/`)
	client := &http.Client{}
	_,err = client.Do(req)
	if err != nil {
		return
	}
	time.AfterFunc(time.Second*10,Get)
}

func main() {
	var g sync.WaitGroup
	g.Add(1)
	Get()
	g.Wait()

}

跑在阿里雲上,訪問量蹭蹭漲,哈哈哈

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章