Python3 Switch tp-link External network IP

Source: Internet
Author: User

Code

#encoding =utf-8#author: walker#date: 2015-08-05#function:  tp-link to switch Ip#memo by disconnecting the connection: This code has been python3.4 tested (for tl-wr847n) Import base64, requests, tracebackdef changeip ():     ip =  ' 192.168.1.1 '     user =  ' admin '      pwd =  ' admin '         desturl =  ' http:/ /'  + ip +  '/userrpm/statusrpm.htm? Disconnect=%b6%cf%20%cf%df&wan=1 '     auth =  ' basic  '  +  Base64.b64encode ((user+ ': ' +pwd). Encode (encoding= ' utf-8 ')). Decode (encoding= ' utf-8 ')      heads = {         ' Accept ':  ' */* ',          ' user-agent ':  ' mozilla/4.0  (compatible; msie 8.0;  windows nt 6.1; wow64; trident/4.0; slcc2; .net clr 2.0.50727;  .net clr 3.5.30729; .net clr 3.0.30729; . net4.0c; . net4.0e) ',         ' Referer '  :  ' http//'  + ip  +  '/userrpm/statusrpm.htm ',         # ' Authorization '  :  Auth ' Cookie ':  ' authorization= '  + auth    }         try:        r = requests.get (Url=desturl,  headers=heads)         print (r)     except:         exMsg =  ' * exmsg:\n '  +  Traceback.print_exc ()         print (exmsg) if __name__ ==   "__main__":     changeip ()

Note

The authentication section cannot be copied completely, and the request header can be analyzed by the browser.


Reference:

1. Restart the Tp-link router with Python (restart)

2, Python login tp-link router for IP script (re-connected)

3, Python One-click Set router


Walker * * *


This article is from "Walker's Journal" blog, please be sure to keep this source http://walkerqt.blog.51cto.com/1310630/1681948

Python3 Switch tp-link External network IP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.