Answers for "beautifulsoup get parent element"

0

beautifulsoup get parent element

>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup('<p>TEXT I WANT <i> – </i></p>')
>>> soup.find('i').parent
<p>TEXT I WANT <i> – </i></p>
>>> soup.find('i').parent.text
u'TEXT I WANT  \u2013 '
Posted by: Guest on September-17-2020

Code answers related to "beautifulsoup get parent element"

Python Answers by Framework

Browse Popular Code Answers by Language