【发布时间】:2018-03-01 20:04:28
【问题描述】:
我已经安装了 html5lib 包。我确定是因为当我尝试安装它时,我会收到一条消息说它已经安装了。
pip install html5lib
Requirement already satisfied: html5lib in ./anaconda/lib/python3.5/site-packages
我也能够成功导入该包。
import html5lib
然而,当我尝试将解析器用作 BeautifulSoup 构造函数的一部分时
soup = BeautifulSoup(response.data, 'html5lib')
我失败了
FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
是否可以强制bs4查找已安装的解析器并成功找到html5lib?
【问题讨论】:
-
我喜欢你想要的
'html.parser'而不是'html5lib'。如果没有,并且您使用的是 pycharm 之类的智能 ide,请重新启动它。 -
html5lib 是我正在寻找的。它与 html.parser 不同。查看列表crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser
-
正确的 python 版本?
-
@MegaIng 重新启动 IDE (Spyder) 工作。我以前在安装软件包并且没有重新启动 IDE 的情况下成功工作,所以从没想过这是我错过的东西。非常感谢!
标签: python beautifulsoup html5lib