Issue
it is possible to filter out only the text from the following structure:
"""<font>
<em>X</em>
and
<em>Y</em>
</font>"""
to obtain the following output:
output = "X and Y"
Solution
Try:
from bs4 import BeautifulSoup
html_doc = """\
<font>
<em>X</em>
and
<em>Y</em>
</font>"""
soup = BeautifulSoup(html_doc, "html.parser")
out = soup.find("font").get_text(strip=True, separator=" ")
print(out)
Prints:
X and Y
Answered By - Andrej Kesely
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.