在一个页面中,我有以下HTML
<div class="ProfileDesc">
<p>
<span class="Title">Name</span>
<span>Tom Ready</span>
</p>
<p>
<span class="Title">Born</span>
<span>
<bxi> 10 Jan 1960</bxi>
<p>
<span class="Title">Death</span>
<span>
<bxi> 01 Jun 2019</bxi>
</span>
</p>
</div>
下面的代码用于从整个页面中提取ProfileDesc
soup = BeautifulSoup(page.content, 'html.parser')
mydivs = soup.find("div", {"class": "ProfileDesc"})
我想要以下输出
Name: Tom Ready
Born: 10 Jan 1960
Death: 01 Jun 2019
找到ProfileDesc后如何提取这些文件
“1960年1月10日”之后的html代码没有结束p标记
当您非常确定DOM结构时:
输出:
试试这个
相关问题 更多 >
编程相关推荐