获取公网ip:
from bs4 import BeautifulSoup
from urllib.request import urlopen
html=urlopen(r'http://2017.ip138.com/ic.asp')
x=BeautifulSoup(html.read(),'html5lib')
y=str(x.center)
print(y[y.index('[')+1:y.index(']')])
获取公网ip:
from bs4 import BeautifulSoup
from urllib.request import urlopen
html=urlopen(r'http://2017.ip138.com/ic.asp')
x=BeautifulSoup(html.read(),'html5lib')
y=str(x.center)
print(y[y.index('[')+1:y.index(']')])