1

运行 python 代码时出现此错误:

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?

所以我在网上搜索并阅读了这个

我检查了我安装的软件包,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 notebook 中运行完全相同的代码时,它运行没有问题。

4

1 回答 1

2

您尝试用“html.parser”替换“ htmllib

例如:

soup = BeautifulSoup(html,"html5lib") **->** soup = BeautifulSoup(data, "html.parser")
于 2018-01-05T04:45:52.157 回答