-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathairwaveApi.py
47 lines (35 loc) · 1.38 KB
/
airwaveApi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import xml.etree.ElementTree as ET
data = 'credential_0=xxxxx&credential_1=xxxxx&destination=/&login=Log In'
headers={'Content-Type': 'application/x-www-form-urlencoded','Cache-Control':'no-cache'}
ampsession = requests.Session()
loginamp = ampsession.post('https://xxx.xx.xx.xxx/LOGIN',headers=headers, data=data, verify=False)
result=ampsession.get('https://xxx.xx.xx.xxx/ap_list.xml',headers=headers, verify=False)
aplist = result.content
tree=ET.fromstring(aplist)
for i in tree.iter('ap'):
id=i.attrib
if i.find('lan_ip')!=None:
ip=i.find('lan_ip').text
else: ip=" "
if i.find('lan_mac')!=None:
mac=i.find('lan_mac').text
else: mac=" "
if i.find('model')!=None:
model=i.find('model').text
else: model=" "
if i.find('name')!=None:
name=i.find('name').text
else: name=" "
if i.find('operating_mode')!=None:
op_mode=i.find('operating_mode').text
else: op_mode=" "
print "\n"+"*"*30
print "#### Details of AP :{}".format(id).ljust(30)
print "*"*30
print "#### AP Name :{}".format(name).ljust(30)
print "#### MAC Address :{}".format(mac).ljust(30)
print "#### IP Address :{}".format(ip).ljust(30)
print "#### Model :{}".format(model).ljust(30)
print "#### Operating Mode:{}".format(op_mode).ljust(30)
print "*" * 30