如何获取公网IP
地址: http://ip.wang-li.top:93/4u6385IP
Linux:
# curl http://ip.wang-li.top:93/4u6385IP
Python:
#!/usr/bin/env python3 import requests def main(): url = "http://ip.wang-li.top:93/4u6385IP" MyIP = requests.get(url).text print(MyIP) if __name__ == '__main__': main()
Go:
package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "http://ip.wang-li.top:93/4u6385IP" resp , err := http.Get(url);if err != nil { fmt.Println("Http Connect Error", err) } else { b , err := ioutil.ReadAll(resp.Body); if err != nil { fmt.Println("Read Body Error" , err) } else { fmt.Printf("%s",b) } } }
(自建返回IP的服务器代码: https://www.cnblogs.com/wang-li/p/11453633.html)
欢迎转发!
请保留源地址: https://www.cnblogs.com/NoneID