1. 程式人生 > >bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html_parser.

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html_parser.

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,還不是很瞭解具體原因,希望後期能夠了解具體的原因。