擅长:python、mysql、java
<p>BeautifulSoup是一个scraping库,因此它可能不是进行HTML渲染的最佳选择。如果没有必要使用BeautifulSoup,您应该看看<a href="https://github.com/Alir3z4/html2text" rel="noreferrer">^{<cd1>}</a>。例如:</p>
<pre><code>import html2text
html = open("foobar.html").read()
print html2text.html2text(html)
</code></pre>
<p>这将输出:</p>
<pre>
Some text more text even more text
* list item
* yet another list item
Some other text
* list item
* yet another list item
</pre>