I am trying to load the table available in 'https://umich-biostatistics.shinyapps.io/covid19/' and navigating to 'Metrics' section in page into a dataframe. Becuase the page loads the data after opening the page, I have tried to use selenium. Could someone help in figuring out my mistake?
import time
from selenium import webdriver
import pandas as pd
chrome_path = r"C:\\Selenium\\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
url = 'https://umich-biostatistics.shinyapps.io/covid19/'
page = driver.get(url)
time.sleep(10)
df = pd.read_html(driver.page_source)[0]
print(df.head())
By running the above code, I am getting the below error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-4781af4c4464> in <module>
10 time.sleep(10)
11
---> 12 df = pd.read_html(driver.page_source)[0]
13 print(df.head())
~\anaconda3\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, thousands, encoding, decimal, converters, na_values, keep_default_na, displayed_only)
1098 na_values=na_values,
1099 keep_default_na=keep_default_na,
-> 1100 displayed_only=displayed_only,
1101 )
~\anaconda3\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
913 break
914 else:
--> 915 raise retained
916
917 ret = []
~\anaconda3\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
893
894 try:
--> 895 tables = p.parse_tables()
896 except ValueError as caught:
897 # if `io` is an io-like object, check if it's seekable
~\anaconda3\lib\site-packages\pandas\io\html.py in parse_tables(self)
211 list of parsed (header, body, footer) tuples from tables.
212 """
--> 213 tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
214 return (self._parse_thead_tbody_tfoot(table) for table in tables)
215
~\anaconda3\lib\site-packages\pandas\io\html.py in _parse_tables(self, doc, match, attrs)
543
544 if not tables:
--> 545 raise ValueError("No tables found")
546
547 result = []
ValueError: No tables found