github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/pcsutil/getip/getip_techain.go (about) 1 package getip 2 3 import ( 4 "bytes" 5 "github.com/fzfile/BaiduPCS-Go/pcsutil/converter" 6 "github.com/fzfile/BaiduPCS-Go/requester" 7 "net/http" 8 ) 9 10 func IPInfoFromTechainBaiduByClient(c *requester.HTTPClient) (ipAddr string, err error) { 11 body, err := c.Fetch(http.MethodGet, "https://techain.baidu.com/srcmon", nil, map[string]string{ 12 "User-Agent": "x18/600000101/10.0.63/4.1.3", 13 "Pragma": "no-cache", 14 "Accept": "*/*", 15 "Content-Type": "application/x-www-form-urlencoded", 16 "x-auth-ver": "1", 17 "Accept-Language": "zh-CN", 18 "x-device-id": "00000000000000000000000000000000", 19 }) 20 if err != nil { 21 return 22 } 23 return converter.ToString(bytes.TrimSpace(body)), nil 24 } 25 26 // IPInfoFromTechainBaidu 从 techain.baidu.com 获取ip 27 func IPInfoFromTechainBaidu() (ipAddr string, err error) { 28 c := requester.NewHTTPClient() 29 return IPInfoFromNeteaseByClient(c) 30 }