Python Selenium: How to get website table into readable format?

  python-3.x, selenium-webdriver, spyder

I’m doing some webscraping for which I’m trying to pull text from an online table.
The table size (columns x rows) varies based off prior user input.
I’ve pulled the table and individual cell values with the below code, but have no way of knowing which cells/indecies I need the corresponding text from. The below variable "y" has the value [WebElement, WebElement, WebElement, etc.]

Is there a way I can convert "y" to a readable format that displays the text from the table? This way I could easily index into which column/row I need.

For example, y[3] reads "apple" but all I see in the variable explorer is ‘WebElement’ unless I specifically call for y[3].text, but I would never know its the 3rd index.

table = driver.find_element_by_id("*table id*")
y = table.find_elements(By.TAG_NAME, "tr")

Source: Python-3x Questions

LEAVE A COMMENT