package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main(){
// token从百度站长获取 https://ziyuan.baidu.com/?castk=LTE%3D
url :="http://data.zz.baidu.com/urls?site=主域名&token=秘钥"
//待推送域名 多推送用\n拆分
jsonStr:=[]byte("域名\n域名2")
req,err:=http.NewRequest("POST",url,bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type","application/json")
client:=http.Client{}
resp,err:=client.Do(req)
if err!=nil{
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
go 发送 body raw 请求 百度主动推送demo
最新推荐文章于 2024-07-23 03:42:01 发布