我正试图用BeautifulSoup将html解析为文本,但我遇到了一个问题:有些单词被不带空格的标记分割:
<span>word1</span><span>word2</space>
所以当我提取文本时,我有:
word1word2
有些句子还与一个句子相连:
INTODUCTION There are many...
有没有一个简单的方法来强制BeautifulSoup标签上的单词分离?也可能是我可以修复一些标签上的句子分离?你知道吗
我有几个复杂的html文件。我把它们处理成文本:
plain_texts = [BeautifulSoup(html, "html.parser").get_text() for html in htmls]
你可以用
replace_with()
方法(docs here)修补你的汤。但这取决于HTML的结构:这张照片:
您可以使用^{} :
分别打印
<span>
标记之间的文本:相关问题 更多 >
编程相关推荐