debug scan
This commit is contained in:
parent
2fc8896339
commit
85959cc0f7
|
@ -78,15 +78,15 @@ def scan_wifi():
|
|||
lines = output.split("\n")[1:] # Skip the header line
|
||||
for line in lines:
|
||||
columns = line.split()
|
||||
'''
|
||||
print(columns)
|
||||
for i, column in enumerate(columns):
|
||||
print(f"{i}: {column}")
|
||||
|
||||
# data = ['94:14:57:15:13:50', 'Meeting', 'MG', 'Infra', '1', '130', 'Mbit/s', '100', '****', 'WPA1', 'WPA2']
|
||||
'''
|
||||
# ['94:14:57:15:13:50', 'Meeting', 'MG', 'Infra', '1', '130', 'Mbit/s', '100', '****', 'WPA1', 'WPA2']
|
||||
|
||||
# 提取MAC地址
|
||||
mac_address = columns[0]
|
||||
print("MAC地址:", mac_address)
|
||||
|
||||
# 提取Wi-Fi名称
|
||||
wifi_names = []
|
||||
|
@ -96,7 +96,6 @@ def scan_wifi():
|
|||
wifi_names.append(wifi_name)
|
||||
columns = columns[i+1:]
|
||||
break
|
||||
print("Wi-Fi名称:", ' '.join(wifi_names))
|
||||
|
||||
# 提取强度
|
||||
strength = None
|
||||
|
@ -104,38 +103,11 @@ def scan_wifi():
|
|||
if columns[i] == 'Mbit/s':
|
||||
strength = columns[i+1]
|
||||
break
|
||||
print("MAC地址:", mac_address)
|
||||
print("Wi-Fi名称:", ' '.join(wifi_names))
|
||||
print("强度:", strength)
|
||||
|
||||
exit()
|
||||
|
||||
|
||||
|
||||
# 分割字符串以空格为分隔符
|
||||
columns = line.split()
|
||||
|
||||
# 提取第一列和第三列的值
|
||||
mac_address = columns[0]
|
||||
|
||||
ssid = " ".join(columns[1:3])
|
||||
if "Infra" in ssid:
|
||||
ssid = ssid.replace(" Infra", "")
|
||||
if ":" in ssid:
|
||||
# "72:A6:CC:8C:89:6C Takway-AI"
|
||||
# 去除字符串中的MAC地址
|
||||
ssid = re.sub(r'\b\w{2}(:\w{2}){5}\b', '', ssid)
|
||||
|
||||
# 提取第六列的强度值
|
||||
last_info = columns[4:8]
|
||||
# 去除所有的空格
|
||||
columns = line.replace(" ", "")
|
||||
# 提取"Mbit/s"后的三位以内数字
|
||||
strength = int(columns[columns.index("Mbit/s")+6:columns.index("Mbit/s")+8])
|
||||
|
||||
# print("MAC地址:", mac_address)
|
||||
# print("SSID:", ssid)
|
||||
# print("强度:", strength)
|
||||
|
||||
wifi_list.append({'ssid': ssid, 'signal': strength})
|
||||
wifi_list.append({'ssid': wifi_names, 'signal': strength, 'mac': mac_address})
|
||||
if len(wifi_list) == 15:
|
||||
break
|
||||
# save wifi_list to file
|
||||
|
|
Loading…
Reference in New Issue