python獲取公網ip的幾種方式

 

python獲取公網ip的幾種方式html

轉 https://blog.csdn.net/conquerwave/article/details/77666226python

  1. from urllib2 import urlopen
  2.  
    my_ip = urlopen( 'http://ip.42.pl/raw').read()
  3.  
    print 'ip.42.pl', my_ip
  4.  
     
  5.  
    from json import load
  6.  
    from urllib2 import urlopen
  7.  
     
  8.  
    my_ip = load(urlopen( 'http://jsonip.com'))['ip']
  9.  
    print 'jsonip.com', my_ip
  10.  
     
  11.  
    from json import load
  12.  
    from urllib2 import urlopen
  13.  
     
  14.  
    my_ip = load(urlopen( 'http://httpbin.org/ip'))['origin']
  15.  
    print 'httpbin.org', my_ip
  16.  
     
  17.  
    from json import load
  18.  
    from urllib2 import urlopen
  19.  
     
  20.  
    my_ip = load(urlopen( 'https://api.ipify.org/?format=json'))['ip']
  21.  
    print 'api.ipify.org', my_ip
  22.  


怎麼在電腦上查看本身的(公網)外網IP和內網IP

相關文章
相關標籤/搜索