This is a nearly-complete rewrite that removes Beautiful Soup's custom
HTML parser in favor of a system that lets you write a little glue
code and plug in any HTML or XML parser you want.
Beautiful Soup 4.0 comes with glue code for four parsers:
Python's standard HTMLParser
lxml's HTML and XML parsers
html5lib's HTML parser
HTMLParser is the default, but I recommend you install one of the
other parsers, or you'll have problems handling real-world markup.
自述文件确实(在某种程度上)涵盖了这个问题,但必须通过阅读本节的行来推断:
旧的自定义解析器基于不推荐使用的sgmllib模块中的
SGMLParser
(在python3中已删除)markupMassage
功能主要用于修复SGMLParser
无法处理的无效标记。所以当旧的自定义解析器消失时,markupMassage
功能也随之出现。在想必,在默认情况下不再提供的任何功能现在都必须通过子类化一个新的解析器来添加。在
因此,如果安装了
lxml
,则需要执行以下操作:相关问题 更多 >
编程相关推荐