使用 Python 将 HTML 转换为纯文本的最佳方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1668081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best way to convert HTML to plaintext using Python
提问by Chip Tol
I'm working on a project that involves converting a large amount of HTML content to plain/text. I have a custom-written module that does the job OK, but I'm wondering if there's some standard tools to help get the job done.
我正在从事一个项目,该项目涉及将大量 HTML 内容转换为纯文本/文本。我有一个自定义编写的模块可以完成这项工作,但我想知道是否有一些标准工具可以帮助完成工作。
回答by tcarobruce
Here's a python library which does HTML parsing:
这是一个进行 HTML 解析的 python 库:
BeautifulSoupis another option.
BeautifulSoup是另一种选择。