用Python重启TP-Link路由器

10980阅读 1评论2013-04-20 tjyyz
分类:Python/Ruby


点击(此处)折叠或打开

  1. # -*- coding: utf-8 -*-
  2. # 重启路由器脚本
  3. #
  4. import urllib2, base64

  5. if __name__ == '__main__':
  6.     # IP for the router
  7.     ip = '192.168.1.1'
  8.     # 登录的用户名和密码
  9.     login_user = 'admin'
  10.     login_pw = 'admin'

  11.     # 请求地址
  12.     url = 'http://' + ip + '/userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7'
  13.     auth = 'Basic ' + base64.b64encode(login_user+':'+login_pw)
  14.     print auth
  15.     heads = { 'Referer' : 'http://' + ip + '/userRpm/SysRebootRpm.htm',
  16.              'Authorization' : auth
  17.     }
  18.     
  19.     # 发送请求
  20.     request = urllib2.Request(url, None, heads)
  21.     response = urllib2.urlopen(request)
  22.     print response.read()

上一篇:用Python改变TP-Link路由器 ADSL拨号的用户名及密码
下一篇:没有了

文章评论