From 69e5cbd4c65f6f61ac540491c1e9811bac72b30b Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 13 May 2023 03:37:09 +0200 Subject: [PATCH] Add files via upload --- content/get_input_fields.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 content/get_input_fields.py diff --git a/content/get_input_fields.py b/content/get_input_fields.py new file mode 100644 index 0000000..49bc4c7 --- /dev/null +++ b/content/get_input_fields.py @@ -0,0 +1,32 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By + + +def get_input_fields( + driver: webdriver.firefox.webdriver.WebDriver, +) -> tuple[list, list]: + extract_list: list[str] = ["header", "date", "header_link", "subheader"] + results: list = [None] * len(extract_list) + found_element_list = driver.find_elements(By.TAG_NAME, "input") + + for i in found_element_list: + value = str(i.get_attribute("value")) + temp_str = i.get_dom_attribute("data-formengine-input-name") + if temp_str is not None: + data_lines = temp_str.split("[") + if len(data_lines) > 0: + data = data_lines[-1] + if len(data) > 1: + data = data[:-1] + else: + data = None + + try: + idx = extract_list.index(data) + except ValueError: + idx = None + + if idx is not None: + results[idx] = value + + return extract_list, results