我在运行python代码时收到此错误:
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
所以我在网上搜索并阅读了这个
我检查了安装的软件包,html5lib 和 six 似乎是最新版本。
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")