Zdobądź tylko elementy dziecięce rodziców piękna zupa
>>> soup.select('li.test > a')
[<a>link1</a>, <a>link3</a>]
Concerned Chimpanzee
>>> soup.select('li.test > a')
[<a>link1</a>, <a>link3</a>]
>>> 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 '