Compare commits
1 Commits
master
...
codecow-pa
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a57af20e7 |
32
updateIP.py
32
updateIP.py
@ -55,35 +55,9 @@ class SignKit:
|
||||
|
||||
|
||||
def get_current_ip():
|
||||
# 定义API列表(主备分离)
|
||||
ip_apis = [
|
||||
'https://myip.ipip.net/json', # 主API
|
||||
# 'https://api.ipify.org?format=json', # 备用API1(证据9)
|
||||
# 'https://api64.ipify.org?format=json', # 备用API2(证据5,8)
|
||||
'https://qifu-api.baidubce.com/ip/local/geo/v1/district',
|
||||
'https://r.inews.qq.com/api/ip2city',
|
||||
# 'https://ipapi.co/json'
|
||||
]
|
||||
|
||||
for api_url in ip_apis:
|
||||
try:
|
||||
response = requests.get(api_url, timeout=5) # 增加超时控制(证据9)
|
||||
response.raise_for_status() # 检查HTTP状态码(证据9)
|
||||
# 打印当前使用api
|
||||
print(f"使用API: {api_url}")
|
||||
# 统一处理不同API的响应格式
|
||||
if 'ipip.net' in api_url:
|
||||
return response.json()['data']['ip'] # 原API格式
|
||||
else:
|
||||
return response.json()['ip'] # 备用API格式(证据5,8,9)
|
||||
|
||||
except requests.exceptions.RequestException as e: # 捕获所有请求异常(证据1,9)
|
||||
error_type = type(e).__name__
|
||||
print(f"API {api_url} 请求失败: [{error_type}] {str(e)}")
|
||||
|
||||
# 所有API均失败时处理
|
||||
print("所有IP API均不可用,请检查网络连接")
|
||||
return None # 明确返回None(证据9)
|
||||
response = requests.get('https://myip.ipip.net/json')
|
||||
data = response.json()
|
||||
return data['data']['ip']
|
||||
|
||||
|
||||
def update_juliang_white_list(ip, JULIANG_KEY, JULIANG_TRADE_NO):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user