Created
December 4, 2021 20:17
-
-
Save k8scat/ec71d54598d6c129f28d9d5094e4a08f to your computer and use it in GitHub Desktop.
华为4G无线路由器2 Pro 自动修改密码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
import time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.webdriver import WebDriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.remote.webelement import WebElement | |
LOGIN_PASSWORD = '' | |
def wait(d: WebDriver): | |
d.implicitly_wait(30) | |
def main(): | |
driver = webdriver.Chrome() | |
try: | |
driver.get('http://192.168.8.1/html/index.html') | |
wait(driver) | |
# login hilink | |
password_input: WebElement = driver.find_element(by=By.ID, value='login_password') | |
password_input.send_keys(LOGIN_PASSWORD) | |
login_btn: WebElement = driver.find_element(by=By.ID, value='login_btn') | |
login_btn.click() | |
time.sleep(5) | |
driver.get('http://192.168.8.1/html/content.html#wifieasy') | |
wait(driver) | |
# update wifi password | |
wifi_password_input: WebElement = driver.find_element(by=By.ID, value='wifi_2g_wpa_key') | |
wifi_password_input.clear() | |
wifi_random_password = ''.join(random.sample(string.digits + string.ascii_letters, 20)) | |
print(wifi_random_password) | |
wifi_password_input.send_keys(wifi_random_password) | |
wifisettings_save_btn: WebElement = driver.find_element(by=By.ID, value='wifi_btn_save') | |
wifisettings_save_btn.click() | |
time.sleep(10) | |
finally: | |
print('Closing driver') | |
driver.quit() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment