所以我有例子
<body>
<div>I have a code
<img href"http://....jpg" />
<p>title image</p>
this so cool
</div>
</body>
然后我希望OUTput看起来像:
I have a code
<img href"http://....jpg" />
title image
this so cool
非常感谢您的帮助
答案 0 :(得分:0)
您可以使用.contents
返回div
内容列表。然后你相应地处理结果。
soup = BeautifulSoup(html, "html.parser")
soup.find("div").contents