运行 python 代码时出现此错误:
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
所以我在网上搜索并阅读了this
我检查了我安装的软件包,html5lib 和 6 似乎都是最新版本。
beautifulsoup4 (4.6.0)
html5lib (1.0.1)
pip (9.0.1)
setuptools (28.8.0)
six (1.11.0)
webencodings (0.5.1)
我想知道这里出了什么问题?
*上下文:
import urllib.request
from bs4 import BeautifulSoup
url0 = 'http://py4e-data.dr-chuck.net/known_by_Cruz.html'
url = url0
name = list()
for i in range(0,7):
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html,"html5lib")
....
当我在 jupyter 笔记本中运行完全相同的代码时,它运行没有问题。
最佳答案
尝试将“html5lib”
替换为“html.parser”
例如:
soup = BeautifulSoup(html,"html5lib")
-> soup = BeautifulSoup(data, "html.parser")
关于python - bs4.FeatureNotFound : Couldn't find a tree builder with the features you requested: html5lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48107191/