Advertisement
Guest User

kucni_red

a guest
May 10th, 2023
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.13 KB | None | 0 0
  1. import subprocess
  2. import random
  3. import time
  4. from selenium import webdriver
  5. from datetime import datetime, timedelta
  6. from datetime import time as vreme
  7. from selenium.webdriver.common.by import By
  8.  
  9. random_minutes = random.randint(0, 75)
  10. start_time = datetime.combine(datetime.now().date(),vreme(hour=0, minute=15)) + timedelta(minutes=random_minutes)
  11.  
  12. while datetime.now() < start_time:
  13.     time_left = start_time - datetime.now()
  14.     print(f"{time_left} do pocetka operacije kucni red...")
  15.     time.sleep(60)
  16. print("operacija kucni red je zapoceta")
  17.  
  18. end_time = datetime.combine(datetime.now().date(), vreme(hour=4, minute=0))
  19.  
  20. while datetime.now() < end_time:
  21.  
  22.     # get the current SSID
  23.     out = subprocess.check_output('netsh wlan show interfaces').decode("utf-8")
  24.     current = out.split("\n")[19].split(": ")[1].strip()
  25.     print(f"Current WiFi: {current}")
  26.  
  27.     # check the SSID
  28.     if current == "xxx":
  29.  
  30.         # Create a new instance of the Chrome driver
  31.         driver = webdriver.Chrome()
  32.  
  33.         # Navigate to the login page
  34.         driver.get("http://192.168.1.1")
  35.  
  36.         # Find the username and password fields and enter your credentials
  37.         username_field = driver.find_element(By.XPATH, '//*[@id="txt_Username"]')
  38.         username_field.send_keys("telekom")
  39.         password_field = driver.find_element(By.XPATH, '//*[@id="txt_Password"]')
  40.         password_field.send_keys("telekom")
  41.  
  42.         # Find the login button and click it
  43.         login_button = driver.find_element(By.XPATH, '//*[@id="button"]')
  44.         login_button.click()
  45.         time.sleep(2) # Wait for 2 seconds
  46.  
  47.         # Click the System Tools tab
  48.         system_tools_tab = driver.find_element(By.XPATH, '//*[@id="headerTab"]/ul/li[11]/div[2]')
  49.         system_tools_tab.click()
  50.         time.sleep(3) # Wait for 3 seconds
  51.  
  52.         iframe= driver.find_element("id", "frameContent")
  53.         driver.switch_to.frame(iframe)
  54.         driver.find_element("id", 'btnReboot').click()
  55.         alert = driver.switch_to.alert.accept()
  56.  
  57.         #time.sleep(120)
  58.     else:
  59.         print(f"Nije to taj WiFi nego je '{current}'")
  60.     time.sleep(180)
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement