环境:Python3.6
使用如下代码时
soup = BeautifulSoup(s, “html”)
报错FeatureNotFound: Couldn’t find a tree builder with the features you requested: lxml. Do you need to install a parser library?
因为可能问题不同,有不同的解决办法
(1)第一种可能:根本没有安装lxml
sudo apt-get install libxml2-dev libxslt-dev python-dev
pip install beautifulsoup4
sudo pip install lxml
(2)第二种可能,缺少包libxslt
pip install libxslt
(3)第三种可能:lxml版本与Python3.6不兼容,需要lxml3.7.3版本
pip install lxml==3.7.3
(4)直接不用lxml。使用python自带的lxml
soup = BeautifulSoup(s, “html.parser”)