python獲取公網ip的幾種方式html
轉 https://blog.csdn.net/conquerwave/article/details/77666226python
-
from urllib2 import urlopen
-
my_ip = urlopen(
'http://ip.42.pl/raw').read()
-
-
-
-
from urllib2 import urlopen
-
-
my_ip = load(urlopen(
'http://jsonip.com'))['ip']
-
print 'jsonip.com', my_ip
-
-
-
from urllib2 import urlopen
-
-
my_ip = load(urlopen(
'http://httpbin.org/ip'))['origin']
-
print 'httpbin.org', my_ip
-
-
-
from urllib2 import urlopen
-
-
my_ip = load(urlopen(
'https://api.ipify.org/?format=json'))['ip']
-
print 'api.ipify.org', my_ip
-
-