fix requests
This commit is contained in:
@ -40,9 +40,9 @@ class WebUtils:
|
||||
}
|
||||
"""
|
||||
try:
|
||||
r = RequestUtils().get_res(f"https://api.mir6.com/api/ip?ip={ip}&type=json")
|
||||
if r:
|
||||
return r.json().get("data", {}).get("location") or ''
|
||||
with RequestUtils().get_res(f"https://api.mir6.com/api/ip?ip={ip}&type=json") as r:
|
||||
if r:
|
||||
return r.json().get("data", {}).get("location") or ''
|
||||
except Exception as err:
|
||||
print(str(err))
|
||||
return ""
|
||||
@ -65,9 +65,9 @@ class WebUtils:
|
||||
}
|
||||
"""
|
||||
try:
|
||||
r = RequestUtils().get_res(f"https://whois.pconline.com.cn/ipJson.jsp?json=true&ip={ip}")
|
||||
if r:
|
||||
return r.json().get("addr") or ''
|
||||
with RequestUtils().get_res(f"https://whois.pconline.com.cn/ipJson.jsp?json=true&ip={ip}") as r:
|
||||
if r:
|
||||
return r.json().get("addr") or ''
|
||||
except Exception as err:
|
||||
print(str(err))
|
||||
return ""
|
||||
|
Reference in New Issue
Block a user