Chinaunix首页 | 论坛 | 博客
  • 博客访问: 260385
  • 博文数量: 27
  • 博客积分: 713
  • 博客等级: 上士
  • 技术积分: 294
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-25 09:09
文章分类
文章存档

2013年(2)

2012年(6)

2011年(15)

2010年(4)

分类: 系统运维

2013-04-20 20:13:24


点击(此处)折叠或打开

  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()


阅读(6345) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~