mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-24 04:19:48 +01:00
commit
671c992f3a
1 changed files with 5 additions and 3 deletions
|
|
@ -67,11 +67,13 @@ def is_private_ip(ip_addr):
|
|||
|
||||
def get_ip_info(ip_addr):
|
||||
try:
|
||||
url = "https://whois.pconline.com.cn/ipJson.jsp?json=true"
|
||||
url = f"https://whois.pconline.com.cn/ipJson.jsp?json=true&ip={ip_addr}"
|
||||
resp = requests.get(url).json()
|
||||
|
||||
ip_info = {
|
||||
"city": resp.get("city")
|
||||
"city": resp.get("city"),
|
||||
"region": resp.get("region"),
|
||||
"addr": resp.get("addr")
|
||||
}
|
||||
return ip_info
|
||||
except Exception as e:
|
||||
|
|
@ -182,4 +184,4 @@ def extract_json_from_string(input_string):
|
|||
match = re.search(pattern, input_string)
|
||||
if match:
|
||||
return match.group(1) # 返回提取的 JSON 字符串
|
||||
return None
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue