获取当前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代码案例

python 复制代码
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()
相关推荐
遇见火星4 分钟前
2025年Linux 安全与运维指南
网络
苏格拉真没有底14 分钟前
python实现mqtt消息转Tcp消息
网络·python·tcp/ip
dxaiofcu18 分钟前
双网卡电脑,IP地址漂移
linux·服务器·网络
煲冬瓜的程序猿3 小时前
BGP(三)联盟、反射器
网络·网络协议
Joeysoda3 小时前
JavaEE进阶(2) Spring Web MVC: Session 和 Cookie
java·前端·网络·spring·java-ee
暴躁的小胡!!!3 小时前
Linux权限维持之vim python 扩展后门(五)
linux·运维·服务器·网络·安全
邵奈一3 小时前
git报错:error: RPC failed; curl 16 Error in the HTTP2 framing layer
git·网络协议·rpc
圣圣不爱学习3 小时前
Calico-BGP FullMesh模式与RR模式 Day04
运维·网络
zhgjx-dengkewen3 小时前
华为eNSP:实验 OSPF单区域
运维·网络·华为·智能路由器
风格6544 小时前
DR和BDR的选举规则
网络·智能路由器