📶 WiFi测试工具

📋 功能说明
  • 获取当前WiFi信号强度
  • 显示已连接WiFi信息
  • 网速测试
💻 源代码
import subprocess
import re
import time
import requests

def get_wifi_info():
    """获取WiFi信息 (Windows)"""
    cmd = 'netsh wlan show interface'
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    info = {}
    for line in result.stdout.split('\n'):
        if 'SSID' in line:
            info['SSID'] = line.split(':')[1].strip()
        elif '信号' in line:
            info['signal'] = line.split(':')[1].strip()
        elif '频道' in line:
            info['channel'] = line.split(':')[1].strip()
        elif '传输速率' in line:
            info['rate'] = line.split(':')[1].strip()
    
    return info

def test_speed():
    """测试网速"""
    url = 'https://speed.cloudflare.com/__down?bytes=10000000'
    start = time.time()
    r = requests.get(url)
    end = time.time()
    
    speed = len(r.content) / (end - start) / 1024 / 1024
    print(f"下载速度: {speed:.2f} MB/s")

# 示例
wifi = get_wifi_info()
print(f"WiFi名称: {wifi.get('SSID', 'N/A')}")
print(f"信号强度: {wifi.get('signal', 'N/A')}")
test_speed()
📦 运行环境
pip install requests
系统要求
  • Windows系统
  • 需管理员权限