pip install beautifulsoup4 bs4.FeatureNotFound: Couldn't find a tree builder

pip install beautifulsoup4
bs4解析网页时报错:bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html_parser. Do you need to install a parser library?

原因:不可以使用 BeautifulSoup(html,'html_parser')

解决办法:

1.安装 pip install lxml

2.将BeautifulSoup(html,'html_parser') 改为BeautifulSoup(html,'lxml')

有人遇到的情况和我的正好相反,由于刚开始接触python,还不是很了解具体原因,希望后期能够了解具体的原因。

posted @ 2021-10-31 16:13  晨光曦微  阅读(117)  评论(0编辑  收藏  举报