Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

python - pandas read_html - no tables found after rendering

I am trying to webscrape the second table (Annual Total Return (%) History) from this yahoo page: https://finance.yahoo.com/quote/SPY/performance/

I am using pandas read_html function, but I get an error saying: no table found. I researched a bit and noticed that the page needs dynamic rendering before being able to scrape the data.

So I did the following thing, after checking a post with a similar problem, but i still get the same error (ValueError: No tables found):

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://finance.yahoo.com/quote/SPY/performance/')

html = driver.page_source
tables = pd.read_html(html)
data = tables[1]

driver.close()

I am not passing a path to webdriver.Chrome() because the chromedriver.exe is already placed in the jupyter notebook directory.

What am I doing wrong?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...