我正在尝试用python连接到WiFi网络到目前为止,我还没有找到任何方法……
from wireless import Wireless
wire = Wireless()
wire.connect(ssid=name,password=pass)
和no luck
'Exception: Unable to auto-detect the network interface.'
另一个尝试:
import winwifi
name='xxxx'
password='11111'
try:
winwifi.WinWiFi.connect(name,password)
print('t')
except Exception as e:
print(e)
没有错误,但是没有连接
i tried:
import winwifi
import time
import os
def createNewConnection(name, SSID, password):
config = """<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>"""+name+"""</name>
<SSIDConfig>
<SSID>
<name>"""+SSID+"""</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>"""+password+"""</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>"""
command = "netsh wlan add profile filename=""+name+".xml""+" interface=Wi-Fi"
with open(name+".xml", 'w') as file:
file.write(config)
os.system(command)
# function to connect to a network
def connect(name, SSID):
command = "netsh wlan connect name="" + name + "" ssid="" + SSID + "" interface=Wi-Fi"
os.system(command)
但是我只能连接到已知的网络