BeautifulSoup finden Klasse
mydivs = soup.findAll("div", {"class": "stylelistrow"})
Tommyom
mydivs = soup.findAll("div", {"class": "stylelistrow"})
li = soup.find('li', {'class': 'text'})
children = li.findChildren("a" , recursive=False)
for child in children:
print child
>>> 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 '
from bs4 import BeautifulSoup
# Html source
html = """
<section>
<div>
<h2>Recent Posts:</h2>
</div>
</section>
"""
# Parse
soup = BeautifulSoup(html, 'html.parser')
# Get h2 tag
h2 = soup.h2
# Print h2 parent
print(h2.parent)