当前位置:   article > 正文

获取当前ip的网站--记录

获取当前ip的网站--记录
  1. https://www.ipuu.net/Home
  2. https://jingjiequ.com/tools/ip
  3. https://www.ip.cn/
  4. https://api.bigdatacloud.net/data/client-ip [个人使用]
  5. http://myip.ipip.net/

使用python获取当前ip代码案例

def get_ip():
    headers = {
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "Cache-Control": "max-age=0",
        "Connection": "keep-alive",
        "Upgrade-Insecure-Requests": "1",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
    }
    url = "https://api.bigdatacloud.net/data/client-ip"
    response = requests.get(url, headers=headers, verify=False)

    # 检查请求是否成功
    if response.status_code == 200:
        ip_address = response.json()["ipString"]  # 获取纯IP地址
        return ip_address
    else:
        logger.warning(f"获取IP响应状态码是:{response.status_code}")
        return False
     
 get_ip()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/988089
推荐阅读
相关标签
  

闽ICP备14008679号