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