main_windows.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //go:build windows
  2. package yu_net
  3. import (
  4. yu_curl "gogs.qqck.cn/s/tools/curl"
  5. yu_json "gogs.qqck.cn/s/tools/json"
  6. )
  7. // Internet 是否可链接互联网
  8. // timeout 单位:毫秒
  9. func Internet(timeout int) bool {
  10. j_curl := yu_curl.NewRequest().SetRdirect(false).SetTimeout(timeout)
  11. defer j_curl.Close()
  12. // www.baidu.com
  13. return j_curl.Get("http://220.181.38.143").RespErr() == nil && j_curl.RespStatusCode() == 500
  14. }
  15. // UnixMilli 获取北京时间戳,13位毫秒单位
  16. // https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp
  17. // timeout 单位:毫秒
  18. func UnixMilli(timeout int) int64 {
  19. j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
  20. defer j_curl.Close()
  21. // https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp
  22. j_curl.Get("https://106.11.52.98/rest/api3.do?api=mtop.common.getTimestamp")
  23. return yu_json.GetBytes(j_curl.RespBody(), "data.t").Int()
  24. }
  25. // UnixMilli1 获取北京时间戳,13位毫秒单位
  26. // https://f.m.suning.com/api/ct.do
  27. // timeout 单位:毫秒
  28. func UnixMilli1(timeout int) int64 {
  29. j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
  30. defer j_curl.Close()
  31. j_curl.Get("https://f.m.suning.com/api/ct.do")
  32. return yu_json.GetBytes(j_curl.RespBody(), "currentTime").Int()
  33. }
  34. // UnixMilli2 获取北京时间戳,13位毫秒单位
  35. // https://api.codingclip.com/v1/toolkit/time
  36. // timeout 单位:毫秒
  37. func UnixMilli2(timeout int) int64 {
  38. j_curl := yu_curl.NewRequest().SetTimeout(timeout).SetSslVerifyHost(yu_curl.SSLVERSION_DEFAULT).SetSslVerifyPeer(false)
  39. defer j_curl.Close()
  40. j_curl.Get("https://api.codingclip.com/v1/toolkit/time")
  41. return yu_json.GetBytes(j_curl.RespBody(), "timestamp").Int()
  42. }