点击(此处)折叠或打开
-
# -*- coding: utf-8 -*-
-
# change the PPPoE username & password on TP-Link Routers
-
#
-
import sys, urllib2, base64
-
-
if __name__ == '__main__':
-
# IP for the router
-
ip = '192.168.1.1'
-
# login username&password for the router
-
login_user = 'admin'
-
login_pw = 'admin'
-
# username&password for ADSL
-
pppoe_user = 'PPPoE_UserName'
-
pppoe_pw = 'PPPoE_Password'
-
-
#Change the PPPoE username
-
url = 'http://' + ip + '/userRpm/PPPoECfgRpm.htm?wantype=2&acc=' + pppoe_user + '&psw=' + pppoe_pw + '&VnetPap=0&linktype=2&Save=%B1%A3+%B4%E6'
-
auth = 'Basic ' + base64.b64encode(login_user+':'+login_pw)
-
heads = {'Referer' : url,
-
'Authorization' : auth
-
}
-
#Send out the request
-
request = urllib2.Request(url, None, heads)
-
response = urllib2.urlopen(request)
- print response.read()