码迷,mamicode.com
首页 > 编程语言 > 详细

tplink定时重启脚本(python)

时间:2020-02-25 13:00:26      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:mamicode   page   route   odi   highlight   code   rpm   com   mic   

# -*- coding: utf-8 -*-
# reboot TP-LINK router script
#
import urllib2
import base64
from datetime import datetime
 
# IP for the routers
routers = [
    {‘ip‘: ‘192.168.1.10‘, ‘user‘: ‘admin‘, ‘pwd‘: ‘88‘}
    #,{‘ip‘: ‘192.168.2.***‘, ‘user‘: ‘***‘, ‘pwd‘: ‘***‘}
]
page_url = ‘/userRpm/SysRebootRpm.htm‘
 
if __name__ == ‘__main__‘:
    for router in routers:
        # make requests
        base_url = ‘http://‘ + router[‘ip‘] + page_url
        url = base_url + ‘?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7‘
        auth = ‘Basic ‘ + base64.b64encode(router[‘user‘]+‘:‘+router[‘pwd‘])
        print datetime.now(), url
        heads = {‘Referer‘: base_url, ‘Authorization‘: auth}
 
        # send requests
        request = urllib2.Request(url, None, heads)
        response = urllib2.urlopen(request)

  

 

0 4 * * * python -u /root/Rreboot/reboot.py >> /root/Rreboot/log

 

技术图片

tplink定时重启脚本(python)

标签:mamicode   page   route   odi   highlight   code   rpm   com   mic   

原文地址:https://www.cnblogs.com/ahuo/p/12360965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!