你好标签时,我喜欢下面:精华内容,包括与BeautifulSoup 4
soup.find('div', id='id1')
我得到这样的:
<div id="id1">
<p id="ptag"> hello this is "p" tag</p>
<span id="spantag"> hello this is "p" tag</span>
<div id="divtag"> hello this is "p" tag</div>
<h1 id="htag"> hello this is "p" tag</h1>
</div>
在哪里,我只需要像这样:
<p id="ptag"> hello this is "p" tag</p>
<span id="spantag"> hello this is "p" tag</span>
<div id="divtag"> hello this is "p" tag</div>
<h1 id="htag"> hello this is "p" tag</h1>
有什么办法可以得到像上面这样的内容吗?我尝试使用.contents,但没有得到我需要的东西。
感谢
谢谢你洙多!!!!为我工作:) –