获取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')
添加回答
举报
0/150
提交
取消