I need to scrape the data from a table that seems to be generated in JavaScript. I'm using selenium
and Python3
for this task. While looking at how others have approached similar challenges, I noticed they use xpath to locate the tables before scraping them. However, I am struggling to determine the correct xpath to use.
How can I extract the content of the table? If xpath is the way to go, how can I identify the right xpath(s) by inspecting the source code of the webpage?
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()