猿问

bs4报错 html5lib. Do you need to install a parser library?

 获取html内容字符串,进行分析
with open('bs1.html',encoding='utf8') as f:
    html_doc = f.read()

# 导入 BeautifulSoup
from bs4 import BeautifulSoup

# 指定用html5lib来解析html文档
soup = BeautifulSoup(html_doc, "html5lib")



# 获取html内容字符串,进行分析
with open('bs1.html',encoding='utf8') as f:
    html_doc = f.read()

# 导入 BeautifulSoup
from bs4 import BeautifulSoup

# 指定用html5lib来解析html文档
soup = BeautifulSoup(html_doc, "html5lib")


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

纸包排骨
浏览 2459回答 8
8回答

大咪

#可以用这个库进行解析 #当然如果你安装了 lxml也可以用lxml,解析节点比较快 soup = BeautifulSoup(html_cont, 'html.parser', from_encoding='utf-8')
随时随地看视频慕课网APP

相关分类

Python
我要回答