导入网页baidu.html
导入库
from bs4 import BeautifulSoup
打开页面,创建BeautifulSoup对象
file = open("./baidu.html", "rb")
html = file.read().decode("utf-8")
bs = BeautifulSoup(html, "html.parser")
BeautifulSoup四大对象内容
1、Tag 标签及其里面的内容(div,head。。。。。)
print(bs.title)
2、NavgableString 标签里面的内容
print(bs.title.string)
3、BeautifulSoup 表示整个文档