python - Extracting data directly from HTML with BeautifulSoup -


i have following html data. need "2" it, using beautifulsoup4:

<td rowspan="2" style="text-align: center; vertical-align: middle;">     <small>3</small> </td> 

i tried:

k.find('rowspan')['style']  

which produced exception:

traceback (most recent call last): file "", line 1, in typeerror: list indices must integers, not str

is possible using bs4? or shouls use different library extract css directly?

why using find("rowspan")? not searching <rowspan> tag.

the find method searches tags based on tag name when single string parameter passed.

what should using this, means, "find first <td> tag attribute value rowspan="2", , return value of style attribute":

k.find('td', rowspan="2")['style'] 

see "kinds of filters" section of docs various ways of specify tags search for.


Comments