from BeautifulSoup import BeautifulSoup
htmls = '''
<div class="main-content">
<h1 class="student">
<p>Name: <br />
Alex</p>
<p> </p>
</h1>
</div>
<div class="department">
... more text
</div>
'''
soup = BeautifulSoup(htmls)
h1 = soup.find("h1", {"class": "student"})
print h1
預期結果
<h1 class="student">
<p>Name: <br />
Alex</p>
<p> </p>
</h1>
但不幸的是返回
<h1 class="student">
</h1>
我的問題是,爲什麼它吃之間的一切p標籤?它是否執行renderContents()?或者它的解析失敗?