from flask import Flask, json from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.desired_capabilities import DesiredCapabilities companies = [{"id": 1, "name": "Company One"}, {"id": 2, "name": "Company Two"}] api = Flask(__name__) class LogIngestion_Faz_LagBehind(): def __init__(self): profile = webdriver.FirefoxProfile() profile.accept_untrusted_certs = True self.driver = webdriver.Firefox(firefox_profile=profile) self.driver.implicitly_wait(15) # for each call such finding or clicking an element, wait at least 15 seconds for page to load up before giving up self.vars = {} def __del__(self): self.driver.quit() def perform_check(self): self.driver.get("https://10.118.14.221/p/login/") self.driver.find_element(By.ID, "username").click() self.driver.find_element(By.ID, "username").send_keys("_api_uptime_user") self.driver.find_element(By.ID, "password").click() self.driver.find_element(By.ID, "password").send_keys("DTKg4ZG6rGbAKxz7") self.driver.find_element(By.ID, "login").click() self.driver.find_element(By.CSS_SELECTOR, "#id_adom_root").click() self.driver.find_element(By.CSS_SELECTOR, ".col-sm-6:nth-child(3) svg").click() text = self.driver.find_element(By.CSS_SELECTOR, ".no-hover:nth-child(1) > .col-msg span:nth-child(2)") print(f"TYPE: {type(text)}, CAPTURED STRING: {text}") @api.route('/logingestion/faz/lagbehind', methods=['GET']) def get_lagbehind(): fazCheck = LogIngestion_Faz_LagBehind() ret = fazCheck.perform_check() del fazCheck return ret #return json.dumps(companies) if __name__ == '__main__': api.run()