2016-11-23 54 views
-1

我想刮一個網站,但我是類描述中感興趣的謊言中的數據:訪問數據

<td class="cars" horse-power="276"></td> 

要使用解析整個表IM:

for row in table.find_all('tr'): 
    column = row.find_all('td') 

我嘗試了各種不同的方法,但目前爲止沒有任何工作。我怎樣才能訪問這些數據?

+0

的可能的複製[如何找到從BeautifulSoup4 html標記特定的數據屬性?](http://stackoverflow.com/questions/24197922/how-find-specific-data-attribute-from- html-tag-in-beautifulsoup4) –

+0

不幸的是,這並不能解決我的問題 – AndriusBer

回答

0
for row in table.find_all('tr'): 
    for td in row.find_all('td'): 
     print td.attrs['class'] 
0
for row in table.find_all('tr'): 
    td_class = [td.get('class') for td in row.find_all('td')] 
    td_horse-power = [td.get('horse-power') for td in row.find_all('td')]