tplink定时重启脚本(python)

Posted 程序之家

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tplink定时重启脚本(python)相关的知识,希望对你有一定的参考价值。

# -*- 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)的主要内容,如果未能解决你的问题,请参考以下文章

linux下的python里面如何用相关的网络模块来重启tp-link路由器?

linux定时任务

Linux定时执行shell

常用python日期日志获取内容循环的代码片段

Crontab定时运行python程序

shell脚本定时重启tomcat