123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //go:build windows
- package yu_net
- import (
- yu_curl "gogs.qqck.cn/s/tools/curl"
- yu_json "gogs.qqck.cn/s/tools/json"
- )
- // Internet 是否可链接互联网
- // timeout 单位:毫秒
- func Internet(timeout int) bool {
- j_curl := yu_curl.NewRequest().SetRdirect(false).SetTimeout(timeout)
- defer j_curl.Close()
- // www.baidu.com
- return j_curl.Get("http://220.181.38.143").RespErr() == nil && j_curl.RespStatusCode() == 500
- }
- // UnixMilli 获取北京时间戳,13位毫秒单位
- // https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp
- // timeout 单位:毫秒
- func UnixMilli(timeout int) int64 {
- j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
- defer j_curl.Close()
- // https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp
- j_curl.Get("https://106.11.52.98/rest/api3.do?api=mtop.common.getTimestamp")
- return yu_json.GetBytes(j_curl.RespBody(), "data.t").Int()
- }
- // UnixMilli1 获取北京时间戳,13位毫秒单位
- // https://f.m.suning.com/api/ct.do
- // timeout 单位:毫秒
- func UnixMilli1(timeout int) int64 {
- j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
- defer j_curl.Close()
- j_curl.Get("https://f.m.suning.com/api/ct.do")
- return yu_json.GetBytes(j_curl.RespBody(), "currentTime").Int()
- }
- // UnixMilli2 获取北京时间戳,13位毫秒单位
- // https://api.codingclip.com/v1/toolkit/time
- // timeout 单位:毫秒
- func UnixMilli2(timeout int) int64 {
- j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
- defer j_curl.Close()
- j_curl.Get("https://api.codingclip.com/v1/toolkit/time")
- return yu_json.GetBytes(j_curl.RespBody(), "timestamp").Int()
- }
|