79332978

Date: 2025-01-06 12:14:13
Score: 0.5
Natty:
Report link

For anyone interested, I managed to make it work by looping over tr_elements in the html source file

from selenium import webdriver
from selenium.webdriver.common.by import By

PATH = "C:\\Program Files (x86)\\chromedriver.exe"
cService = webdriver.ChromeService(executable_path= PATH)
driver = webdriver.Chrome(service = cService)
href_links = []
date = "1.5.2025"
driver.get("https://mydata.com")
tableID = driver.find_element(By.CLASS_NAME,"DetailTable")
tbody = tableID.find_element(By.TAG_NAME,"tbody")
tr_elements = [tbody.find_elements(By.TAG_NAME,"tr") for tbody in tbodies]

links = [[] for i in range(len(tr_elements))]

for i in range(len(links)):
    for tr_element in tr_elements[i]:
        td_elements = tr_element.find_elements(By.TAG_NAME,'td')
        temp = td_elements[1].find_element(By.TAG_NAME,"span").get_attribute("innerHTML")
        temp = temp.strip()
        if temp==date:
            temp_link = td_elements[5].find_element(By.TAG_NAME,'center')
            temp_link = temp_link.find_element(By.TAG_NAME,"a")
            links[i].append(temp_link)

This just picks apart each tr element into separate td elements and checks the date against the td containing the date and then returns the href value of the td element containing the href I need

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: weyronn12934