【发布时间】:2011-01-19 16:05:09
【问题描述】:
正在寻找一种更好的方法来获取机器当前的外部 IP #...以下工作,但宁愿不依赖外部站点来收集信息...我仅限于使用捆绑的标准 Python 2.5.1 库使用 Mac OS X 10.5.x
import os
import urllib2
def check_in():
fqn = os.uname()[1]
ext_ip = urllib2.urlopen('http://whatismyip.org').read()
print ("Asset: %s " % fqn, "Checking in from IP#: %s " % ext_ip)
【问题讨论】: