-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (27 loc) · 850 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (27 loc) · 850 Bytes
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
import sys, mechanize, random, json
# Import Config
with open('config.json') as json_data_file:
config = json.load(json_data_file)
# Setup Browser
br = mechanize.Browser()
br.set_handle_robots(False)
# Login
br.open(config["router"]["login_uri"])
print br.title()
br.select_form(nr=0)
br.form['loginUsername'] = config["router"]["user"]
br.form['loginPassword'] = config["router"]["password"]
br.submit()
# Go to the right page
br.open(config["router"]["wireless_uri"])
print br.title()
br.select_form(name='wlanRadio')
print br
channels = [x for x in br.form.possible_items('ChannelNumber') if x not in br.form['ChannelNumber']]
br.form['ChannelNumber'] = [random.choice(channels)]
br.find_control('commitwlanRadio').readonly = False
br.form['commitwlanRadio'] = '1'
br.form['Band'] = ['1']
resp=br.submit()
resp=resp.get_data()
#print resp