擅长:python、mysql、java
<p>根据我的评论,<a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/#differences-between-parsers" rel="nofollow">BS4 handles invalid HTML differently depending on which parser you use</a>。<a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser" rel="nofollow">four parsers that are supported</a>是:</p>
<ul>
<li>你知道吗html.parser语法分析器(内置)</li>
<li>lxml的HTML解析器</li>
<li>lxml的XML解析器</li>
<li>html5lib(在本例中有效)</li>
</ul>
<p>您可以使用试错法,或者具体查看您的问题以及每个解析器处理问题的方式(使用上面的链接),然后选择一个按照您希望的方式运行的解析器。你知道吗</p>