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
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16