Issue
<td>945.000 (<font color="blue">+3.000</font>)</td>
I want to get only the 945.000 inside the tag but there is another element inside it, how can I do it?. Using .string returns none and I think it's because the font color inside it.
Solution
I have taken data as html
you can find td
tag and find text using .text
method or .get_text
then split the data which returns as list
format
html="""<td>945.000 (<font color="blue">+3.000</font>)</td>
"""
from bs4 import BeautifulSoup
soup=BeautifulSoup(html,"html.parser")
soup.find("td").text.split(" ")[0]
Output:
945.000
Answered By - Bhavya Parikh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.