版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Kwoky/article/details/82890689
tag_p = """ <p> 目标文本 <a>子节点文本</a> </p> """ bs4_p = BeautifulSoup(tag_p) print(bs4_p.p.contents) print(bs4_p.p.contents[0].strip())
tag_p = """ <p> 目标文本 <a>子节点文本</a> </p> """ bs4_p = BeautifulSoup(tag_p) print(bs4_p.p.contents) print(bs4_p.p.contents[0].strip())