import requests

URL = 'http://ip.taobao.com/service/getIpInfo.php'  # 淘宝IP地址库API
try:
    r = requests.get(URL, params={'ip': '8.8.8.8'}, timeout=1)
    r.raise_for_status()  # 如果响应状态码不是 200,就主动抛出异常
except requests.RequestException as e:
    print(e)
else:
    result = r.json()
    print(type(result), result, sep='\n')

 

相关文章:

  • 2021-09-03
  • 2021-09-26
  • 2021-07-02
  • 2022-01-13
  • 2021-10-04
  • 2022-01-02
  • 2022-01-03
  • 2022-02-25
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-01-02
相关资源
相似解决方案