Last active
November 12, 2022 13:59
-
-
Save grimpy/02ae10296689b692892a30dbcf7d98ea to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import time | |
import os | |
from selenium import webdriver | |
from selenium.webdriver.firefox.options import Options | |
from selenium.webdriver.support.wait import WebDriverWait | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as EC | |
from IPython import embed | |
def click_frame(driver, x, y, context=False): | |
element = driver.find_element(By.CSS_SELECTOR, "body") | |
action = webdriver.common.action_chains.ActionChains(driver) | |
action.move_to_element_with_offset(element, x, y) | |
if context: | |
action.context_click() | |
else: | |
action.click() | |
action.perform() | |
def open_telenet(driver, url): | |
print("Loading url", url) | |
driver.get("https://telenet.tv") | |
wait = WebDriverWait(driver, 300) | |
wait.until(EC.url_to_be("https://www.telenet.tv/nl/home")) | |
click_frame(driver, 0, 50) | |
wait = WebDriverWait(driver, 10) | |
print("Waiting for 2", time.time()) | |
wait.until(EC.number_of_windows_to_be(2)) | |
print("Waiting for 1", time.time()) | |
wait.until(EC.number_of_windows_to_be(1)) | |
print("checking login") | |
while True: | |
username = driver.execute_script("return window.localStorage.getItem(arguments[0]);", "flutter.username") | |
if username: | |
break | |
print("check login again") | |
time.sleep(0.1) | |
if url: | |
driver.get(url) | |
driver.fullscreen_window() | |
while True: | |
try: | |
time.sleep(300) | |
except KeyboardInterrupt: | |
return | |
if __name__ == "__main__": | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-u", "--url") | |
options = parser.parse_args() | |
print("Opening browser") | |
weboptions = Options() | |
weboptions.add_argument("-profile") | |
weboptions.add_argument("/var/lib/kodi/.mozilla/firefox/6w091ohk.default-release") | |
# weboptions.add_argument("/tmp/myprofile") | |
with webdriver.Firefox(options=weboptions) as driver: | |
open_telenet(driver, options.url) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment