为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

纸包排骨 2018-08-08 11:35:45
 获取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?
查看完整描述

8 回答

?
大咪

TA贡献785条经验 获得超332个赞

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


查看完整回答
反对 回复 2018-08-08
  • 8 回答
  • 0 关注
  • 2372 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信