You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
import subprocess |
|
import requests |
|
from selenium import webdriver |
|
from selenium.webdriver.chrome.options import Options |
|
from time import sleep |
|
|
|
while True: |
|
wlan = subprocess.Popen(['iwgetid'], stdout=subprocess.PIPE) |
|
wlan =wlan.communicate()[0].decode() |
|
if '4G-UFI-5671' in wlan: |
|
print('Sucess') |
|
break |
|
else: |
|
sleep(20) |
|
|
|
print('Nuvarande ip:', requests.get('https://api.ipify.org').text) |
|
|
|
# Set up selenium browser |
|
options = Options() |
|
options.headless = True |
|
browser = webdriver.Chrome(options=options) |
|
|
|
# Login to modem |
|
browser.get('http://192.168.100.1/cellweb/login.asp') |
|
sleep(3) |
|
username = browser.find_element_by_id("user_name") |
|
password = browser.find_element_by_id("user_password") |
|
username.send_keys("admin") |
|
password.send_keys("1340asde") |
|
|
|
# Go to reboot and accept |
|
browser.find_element_by_xpath("/html/body/section/form/button").click() # Login |
|
sleep(1) |
|
browser.find_element_by_xpath("/html/body/section/div[2]/div[6]/a").click() # More |
|
sleep(1) |
|
browser.find_element_by_xpath("/html/body/section[2]/div/div[2]/div/a").click() # Reboot |
|
sleep(1) |
|
browser.find_element_by_xpath("/html/body/div[4]/div/div/div[2]/div[2]").click() # Accept |
|
sleep(1) |
|
browser.switch_to_alert().accept() # Accept again (alert) |
|
browser.close() |
|
sleep(120) |
|
|
|
|
|
print('Ny ip:', requests.get('https://api.ipify.org').text)
|
|
|