对ip列表逐个ping,取响应时间最小的,作为最佳ip。
将ip地址和translate.googleapis.com拼接,复制到剪贴板,方便手动写入到Hosts文件(C:\Windows\System32\drivers\etc\hosts)里面。
只提供设置参考,不能直接帮你设置hosts文件,懒得写!
与IP来源提供的软件相比,唯一优势就是,快!一般10秒内出结果。自己下载来感受下就知道了
172.253.114.90
172.217.203.90
172.253.112.90
142.250.9.90
172.253.116.90
142.250.97.90
142.250.30.90
142.250.111.90
172.217.215.90
142.250.11.90
142.251.9.90
108.177.122.90
142.250.96.90
142.250.100.90
142.250.110.90
172.217.214.90
172.217.222.90
142.250.31.90
142.250.126.90
142.250.10.90
172.217.195.90
172.253.115.90
142.251.5.90
142.250.136.90
142.250.12.90
142.250.101.90
172.217.192.90
142.250.0.90
142.250.107.90
172.217.204.90
142.250.28.90
142.250.125.90
172.253.124.90
142.250.8.90
142.250.128.90
142.250.112.90
142.250.27.90
142.250.105.90
172.253.126.90
172.253.123.90
172.253.122.90
172.253.62.90
142.250.98.90
142.250.185.238
142.251.116.101
216.58.214.14
142.250.189.206
216.58.209.174
142.250.203.142
142.250.218.14
142.251.10.138
142.251.40.174
142.250.185.174
172.217.16.46
172.217.0.46
172.217.31.142
216.58.220.142
172.217.13.142
172.253.113.90
核心源码:(末尾提供完整源码下载)
def pingInfo(ip):
'''ping ip 获取ms 最终取最小值'''
cmd = f'ping /n 1 {ip}'
for echoTxt in os.popen(cmd):
if '请求超时。' in echoTxt:
ipAndSpeed.append([ip, 999])
print(ip, '超时')
return
if echoTxt := echoTxt.strip():
echoTxt = echoTxt.replace(' ', '')
if ',平均=' in echoTxt:
ms = int(echoTxt.split('=')[-1].replace('ms', '')) # 分割平均=xxms
ipAndSpeed.append([ip, ms])
print(ip, f'{ms}ms')
return