컴퓨터/Python
python findAll
풍경소리^^
2019. 6. 24. 06:28
https://www.youtube.com/watch?v=pxRQN9XzLQ0&list=PLAdQRRy4vtQREMg7H7-zFPSOYS6xF1gIL&index=29
from bs4 import BeautifulSoup
html="""
<html>
<table>
<tr>
<td class='first'>"시작가"</td>
<td>"고가"</td>
</tr>
<tr>
<td>"저가"</td>
<td>"종가"</td>
</tr>
</table>
</html>
"""
bs_obj=BeautifulSoup(html,"html.parser")
# td_first=bs_obj.find("td",{"class":"first"})
table=bs_obj.find("table")
tr=table.findAll("tr")[1]
tds=tr.findAll("td")[1].text
print(tds)