赞
踩
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()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。