如何在python中使用BeautifulSoup移动到标记的末尾?

如何在python中使用BeautifulSoup移动到标记的末尾?,python,tags,beautifulsoup,Python,Tags,Beautifulsoup,我的html格式如下: html = '<html><table>this is a table<p>some text</p></table><p>text outside of table</p></html>' 这段代码给了我: <p>some text</p> 一些文本 但是,我希望它能给我: <p>text outside of table</

我的html格式如下:

html = '<html><table>this is a table<p>some text</p></table><p>text outside of table</p></html>'
这段代码给了我:

<p>some text</p>
一些文本

但是,我希望它能给我:

<p>text outside of table</p>
表外文本

主要的问题是,我不能总是将标记指定为“p”标记。我可以使用如下html:

html = '<html><table>this is a table<td>some text</td></table><table>text outside of table</table></html>'
html='这是一个表某些文本在表之外'
所以,我不能真正依靠标签标识符来访问下一个。在上面的代码中,我想返回:

<table>text outside of table</table>
表外文本
我意识到我可以只使用findNext两次,但通常每个表中都有数百个标记,因此无法使用

test = table.nextSibling
为你工作?

会吗

test = table.nextSibling

为你工作?

哇,我觉得自己很笨。我尝试使用findNextSibling,但它不起作用。我想我应该更仔细地阅读文档。谢谢。哇,我觉得自己很笨。我尝试使用findNextSibling,但它不起作用。我想我应该更仔细地阅读文档。谢谢