在这种情况下,您需要一些东西来为您运行该javascript代码。
一种选择是使用selenium
:
from pandas.io.html import read_html
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www1.nyse.com/about/listed/IPO_Index.html')
table = driver.find_element_by_xpath('//div[@class="sp5"]/table//table/..')
table_html = table.get_attribute('innerHTML')
df = read_html(table_html)[0]
print df
driver.close()
印刷品:
0 1 2 3
0 Name Symbol NaT NaN
1 Performance Sports Group Ltd. PSG 2014-06-20 NaN
2 Century Communities, Inc. CCS 2014-06-18 NaN
3 Foresight Energy Partners LP FELP 2014-06-18 NaN
...
79 EGShares TCW EM Long Term Investment Grade Bon... LEMF 2014-01-08 NaN
80 EGShares TCW EM Short Term Investment Grade Bo... SEMF 2014-01-08 NaN
[81 rows x 4 columns]