一 代码
from time import sleep
from socket import gethostbyname
from datetime import datetime
def get_ipAddresses(url):
ipAddresses=[0]
whileTrue:
sleep(0.5)
ip = gethostbyname(url)
if ip != ipAddresses[-1]:
ipAddresses.append(ip)
print(str(datetime.now())[:19]+'===>'+ip)
get_ipAddresses(r'www.microsoft.com')
二 运行结果
2017-06-01 20:50:54===>117.34.19.66