I have some html that I want to extract text from. Here's an example of the html:
<p>TEXT I WANT <i> – </i></p>
up = soup.select('p i').parent
up = soup.select('i')
'list' object has no attribute "parent"
i_tag = soup.find('i') my_text = str(i_tag.previousSibling).strip()
'TEXT I WANT'
As mentioned in other answers,
find_all() returns a list, whereas
find() returns the first match or
If you are unsure about the presence of an i tag you could simply use a