Python自动重启中国移动子母光猫/网关

广告位招租!
知识无价,人有情,无偿分享知识,希望本条信息对你有用!

本工具基于以下博文代码修改所得: 

Python自动重启中国移动光猫(ZXHN G7611V2)https://blog.csdn.net/ncutyb123/article/details/163782841?spm=1001.2014.3001.5501Python自动重启中国移动子光猫 ZXHN G1612https://blog.csdn.net/ncutyb123/article/details/163870922?spm=1001.2014.3001.5501本工具基于Python3.10,实现以无痕模式启动Chome浏览器,登录并重启中国移动光猫:

主网关型号:ZXHN G7611V2

子网关型号:ZXHN G1612

import requests
from requests.auth import HTTPBasicAuth
import os
import webbrowser
from bs4 import BeautifulSoup
import re
import subprocess


from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver import ActionChains
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.mouse_button import MouseButton

# Reboot subgateway

# 替换成你自己的文件路径
subprocess.run(['python', r'C:\Users\David\Desktop\Reboot_Modem\RebootSubGateway.py'])


# 指定 ChromeDriver 的路径
service = Service(r'C:\Users\David\Desktop\Reboot_Modem\chromedriver-win64\chromedriver.exe')

# 创建Chrome选项对象
chrome_options = Options()

# 添加无痕模式参数
chrome_options.add_argument("--incognito")

# 初始化 Chrome WebDriver
driver = webdriver.Chrome(service=service, options=chrome_options)


# 打开网页
driver.get("http://192.168.1.1")


# 替换为你的密码
ModemUser = "user"
ModemPassWord = "YourPassWord"


# 等待页面加载完成(可选)
wait = WebDriverWait(driver, 15)
username = wait.until(EC.presence_of_element_located((By.NAME, "Username")))
password = driver.find_element(By.NAME, "Password") 
username.send_keys(ModemUser)  
password.send_keys(ModemPassWord) 
password.send_keys(Keys.RETURN)  # 提交表单


wait = WebDriverWait(driver, 20)
# 打开网页
driver.get("http://192.168.1.1/start.ghtml")
wait = WebDriverWait(driver, 15)


# Reboot main gateway
iframe = driver.find_element(By.ID, 'mainFrame')
driver.switch_to.frame(iframe)


button = driver.find_element(By.ID, "mmManager")
button.click()

wait = WebDriverWait(driver, 5)

button = driver.find_element(By.ID, "smSysMgr")
button.click()
wait = WebDriverWait(driver, 10)

button = driver.find_element(By.NAME, "Submit1")
button.click()

button = driver.find_element(By.ID, "msgconfirmb")
button.click()

# 关闭浏览器
driver.quit()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

OptimizationMaster

有钱捧个钱场,没钱捧个人场

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值