0
このコードは、すべてのタグを出力します:印刷終了タグ
soup = BeautifulSoup.BeautifulSoup(html)
for child in soup.recursiveChildGenerator():
name = getattr(child, "name", None)
if name is not None:
print name
はあまりにも終了タグをプリントアウトすることが可能ですか?
例:
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
プリント:
html
body
h1
p
は、私はそれを印刷したい:ないそのメカニズムと
html
body
h1
/h1
p
/p
/body
/html