import requests

def getPublicIP():
    url = 'https://www.op123.ren/myip'
    try:
        response = requests.get(url, timeout=1, verify=False)
        response.raise_for_status()  # 确保请求成功
        return response.text  # 打印响应内容
    except requests.RequestException as e:
        print(f"请求出错: {e}")
        return "None"


# IP地址和端口
public_ip_address = getPublicIP()
body+="\r\n"
print(f"公网地址是:{public_ip_address}")
body+=f"公网地址是:{public_ip_address}"
body+="\r\n"

最后修改:2024 年 05 月 11 日
如果觉得我的文章对你有用,请随意赞赏