有没有办法在Python中将html转换为文本。我正在寻找干净的文本,应该有适当的间距和新行。
我尝试过 BeautifulSoup,但我看到了如下所示的重叠文本。
from bs4 import BeautifulSoup
html = """Html code"""
soup = BeautifulSoup(html,'lxml')
print(soup.get_text())
我得到以下输出
Retrieving image informationConverting image formatsScaling, cropping, and rotating imagesAdding image, text, and....
但是这应该被适本地间隔(粗体)。
还有其他模块吗?
HTML Source .
最佳答案
关于python - 如何在python中将html转换为文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47089570/