获取本机公网IP
方法一
| curl http://pv.sohu.com/cityjson 2>> /dev/null | awk -F '"' '{print $4}'
|
方法二
|
from urllib import request import re
url = request.urlopen("http://txt.go.sohu.com/ip/soip") text = str(url.read()) ip = re.findall(r'\d+.\d+.\d+.\d+',text)
print(ip[0])
|