标签: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
标签:mamicode page route odi highlight code rpm com mic
原文地址:https://www.cnblogs.com/ahuo/p/12360965.html