2017-06-01 61 views
0

我試圖使用beautifulsoup在以下鏈接表來分析數據屬性,beautifulsoup分析表在Python

http://hk.warrants.com/home/en/sgdata/list_e.cgi#topsearch

由於該表中沒有階級屬性或ID ,我無法使用soup.find(「table」,{「title」:「TheTitle」})的常規方法來查找表格。相反,我已經盡力了,

warrantUrl = 'http://hk.warrants.com/home/en/sgdata/list_e.cgi#topsearch' 
warrantPage = urlopen(warrantUrl) 
soup = BeautifulSoup(warrantPage, 'html.parser') 
table = soup.find_all("tr") 
paragraphs = [] 
for x in table: 
    paragraphs.append(str(x)) 

另外,我想在這個崗位, Parse table with BeautifulSoup Python提到的方法。但沒有成功...

回答

0

該網站使用javascript,BeautifulSoup無法將其轉換爲html,它無法處理它,urllib也不能,你需要檢查出Ghost for python。

http://jeanphix.me/Ghost.py/

閱讀文檔,它真的很簡單,功能強大,類似的請求。它有能力「評估」JavaScripts並以各種方式返回它們的值。

+0

謝謝你,會研究那一個。 – ppp5000

+0

檢查一下,如果你需要任何幫助,請不要猶豫,問問 –