用Python改变TP-Link路由器 ADSL拨号的用户名及密码

6430阅读 0评论2013-04-20 tjyyz
分类:系统运维


点击(此处)折叠或打开

  1. # -*- coding: utf-8 -*-
  2. # change the PPPoE username & password on TP-Link Routers
  3. #
  4. import sys, urllib2, base64

  5. if __name__ == '__main__':
  6.     # IP for the router
  7.     ip = '192.168.1.1'
  8.     # login username&password for the router
  9.     login_user = 'admin'
  10.     login_pw = 'admin'
  11.     # username&password for ADSL
  12.     pppoe_user = 'PPPoE_UserName'
  13.     pppoe_pw = 'PPPoE_Password'
  14.     
  15.     #Change the PPPoE username
  16.     url = 'http://' + ip + '/userRpm/PPPoECfgRpm.htm?wantype=2&acc=' + pppoe_user + '&psw=' + pppoe_pw + '&VnetPap=0&linktype=2&Save=%B1%A3+%B4%E6'
  17.     auth = 'Basic ' + base64.b64encode(login_user+':'+login_pw)
  18.     heads = {'Referer' : url,
  19.         'Authorization' : auth
  20.     }
  21.     #Send out the request
  22.     request = urllib2.Request(url, None, heads)
  23.     response = urllib2.urlopen(request)
  24.     print response.read()


上一篇:Call EventHistoryCollector.SetLatestPageSize for Object
下一篇:用Python重启TP-Link路由器