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

标签 python python-3.x beautifulsoup html5lib

运行 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/

相关文章:

python - “列表”对象没有属性 'click'

python - 如何将字符串添加到文件中的奇数行?

php - 无法让 PHP 接受漂亮的 Python 汤脚本中的 POUND 符号

python - 如何让我的代码停止在网络爬虫中打印关键字

python - 用于安全的目的是什么?

python - 如何从多个网页中提取文本,其中某些页面在不同标签下有文本?

python - 命令行输入、极端和 map 模式 python

Python:使用另一个列表中的索引汇总列表中的数据

python - 在嵌套字典中查找最大值

python - 使用一个完全训练的文件和另一个完全测试的文件进行分类