如何获取公网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)
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/wang-li/p/11437310.html