获取公网IP

http://httpbin.org/get

www.net.cn

req = requests.get("http://www.net.cn/static/customercare/yourip.asp")
find_ip = re.compile('<h2>((d{1,3})(.d{1,3}){3})</h2>')
cc = find_ip.findall(req.text)

print(cc)
('234.138.196.174', '234, '.174')

##得出根据分组最外层的分组为整体,内层第一个分组为第二个,内层第二个分组为最后一个匹配


##本机IP
cc[0][0]

pconline

http://whois.pconline.com.cn/?ip=117.89.35.98#tabs-1
http://whois.pconline.com.cn/ipJson.jsp
原文地址:https://www.cnblogs.com/g2thend/p/12209116.html