summaryrefslogtreecommitdiffstats
path: root/uptime-mediator.py
blob: 3d097c2093be8af26998ce00f812e016102a3519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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()