from selenium import webdriver import time #from datetime import * #import sendmessage def restart_router(): try: browser = webdriver.Chrome() browser.get("http://192.168.1.1") browser.implicitly_wait(30) browser.find_element_by_xpath("//*[@id=‘pcPassword‘]").send_keys("haohao123") browser.find_element_by_id("loginBtn").click() time.sleep(5) browser.switch_to_frame("bottomLeftFrame") browser.find_element_by_xpath(‘//*[@id="a39"]‘).click() browser.find_element_by_xpath(‘//*[@id="a45"]‘).click() browser.switch_to_default_content() browser.switch_to_frame("mainFrame") browser.find_element_by_xpath(‘//*[@id="reboot"]‘).click() time.sleep(5) browser.switch_to_alert().accept() time.sleep(20) finally: browser.quit() if __name__ == ‘__main__‘: while True: try: interval=60*80 time_remaining = interval - time.time() % interval print("Sleeping until %s (%s seconds)..." % ((time.ctime(time.time() + time_remaining)), time_remaining)) print(time_remaining) time.sleep(time_remaining) print("Starting command.") restart_router() print(‘重启路由器成功‘) print("-"*100) except Exception as e: print(e)
原文地址:https://www.cnblogs.com/liangyf/p/10305934.html
时间: 2024-10-12 03:06:43