I'm trying to scrape the contents of a table. I believe the table is rendered in JavaScript, so I'm using the selenium
package and Python3
. To do such a task, I've seen others find the tables xpath
in order to scrape its contents, but I'm just not sure how to identify the correct xpath.
How can I extract the tables contents? If using a xpath, how do I identify the correct xpath(s) corresponding to the table or its contents by inspecting the web page's source?
from selenium import webdriver
driver = webdriver.Chrome('path/to/chromedriver.exe')
url = https://ultrasignup.com/results_event.aspx?did=6727
driver.get(url)
# Now I need to get the tables contents. I might do something like this:
table = driver.find_elements_by_xpath('my_xpath')
table_html = table.get_attribute('innerHTML') # not sure what innerHTML is...
df = read_html(table_html)[0]
print(df)
driver.close()