BeautifulSoup4 parsing with lxml as the backend may have issues in Windows if lxml is not installed properly.
I encountered BS4 not correctly parse html content when lxml is installed with pip.
I red the lxml’s FAQ:
Two of the major design issues of this operating system make it non-trivial for its users to build lxml: the lack of a pre-installed standard compiler and the missing package management.
Christoph Gohlke generously provides unofficial lxml binary builds for Windows that are usually very up to date. Consider using them if you prefer a binary build over a signed official source release.
After installed Christoph Gohlke’s lxml package, the issue gone.
本文介绍了在Windows环境下使用BeautifulSoup4 (BS4) 配合lxml后端进行HTML解析时可能遇到的问题及解决方案。由于Windows操作系统特有的限制,可能导致lxml安装不正确,进而使得BS4无法正常解析HTML内容。文章推荐使用Christoph Gohlke提供的未正式签署的lxml二进制包来解决这一问题。
990

被折叠的 条评论
为什么被折叠?



