getIp.py 418 B

123456789
  1. import requests
  2. import json
  3. import time
  4. while True:
  5. header = {"accept":"application/json, text/javascript, */*; q=0.01","user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}
  6. resp = requests.get("https://ip.cn/api/index?ip=&type=0",headers=header)
  7. rs = json.loads(resp.text)
  8. print("当前IP:"+rs["ip"])
  9. time.sleep(10)