认证采用的是get的方式,参数大家可以根据自己校园网情况更改。
import requests
import socket
import json
import os
def get_local_ip():
try:
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect(("8.8.8.8", 80)) # 连接到Google公共DNS
return s.getsockname()[0]
except Exception as e:
print(f"获取本地 IP 地址时出错: {e}")
return None
def get_isp_suffix(isp_choice):
if isp_choice == '1':
return '@kjxydx' # 电信
elif isp_choice == '2':
return '@kjxyyd' # 移动
elif isp_choice == '3':
return '@kjxylt' # 联通
else:
print("无效的选择。")
return None
def save_credentials(data):
with open('credentials.json', 'w') as f:
json.dump(data, f, ensure_ascii=False, indent=4)
def load_credentials():
if os.path.exists('credentials.
标签:return,socket,python,isp,认证,credentials,校园网,import,choice
From: https://blog.csdn.net/m0_74369486/article/details/142915985