python获取公网ip的几种方式

2023-01-31 02:01:26 获取 公网 几种
from urllib2 import urlopen
my_ip = urlopen('Http://ip.42.pl/raw').read()
print 'ip.42.pl', my_ip

from JSON import load
from urllib2 import urlopen

my_ip = load(urlopen('http://jsonip.com'))['ip']
print 'jsonip.com', my_ip

from json import load
from urllib2 import urlopen

my_ip = load(urlopen('http://httpbin.org/ip'))['origin']
print 'httpbin.org', my_ip

from json import load
from urllib2 import urlopen

my_ip = load(urlopen('https://api.ipify.org/?fORMat=json'))['ip']
print 'api.ipify.org', my_ip

相关文章