Merge pull request #574 from LinZeb906791229/main

get_ip_info接口优化
This commit is contained in:
hrz
2025-03-29 09:06:05 +08:00
committed by GitHub
+2 -4
View File
@@ -67,13 +67,11 @@ def is_private_ip(ip_addr):
def get_ip_info(ip_addr):
try:
base_url = "https://freeipapi.com/api/json"
url = base_url if is_private_ip(ip_addr) else f"{base_url}/{ip_addr}"
url = "https://whois.pconline.com.cn/ipJson.jsp?json=true"
resp = requests.get(url).json()
ip_info = {
"city": resp.get("cityName")
"city": resp.get("city")
}
return ip_info
except Exception as e: