“BeautifulSoup pai” Respostas de código

BELAGEMSUPEL ENCONTRAR CLASSE

mydivs = soup.findAll("div", {"class": "stylelistrow"})
Tommyom

filhos lindos sopa

li = soup.find('li', {'class': 'text'})
children = li.findChildren("a" , recursive=False)
for child in children:
    print child
Long Lyrebird

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 '
Disgusted Dugong

BeautifulSoup pai

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)
Cooperative Cicada

Respostas semelhantes a “BeautifulSoup pai”

Perguntas semelhantes a “BeautifulSoup pai”

Procure respostas de código populares por idioma

Procurar outros idiomas de código