html = """
<html><head><title>The Dormouse's story</title></head><body><pclass="title"name="dromouse"><b>The Dormouse's story</b></p><pclass="story">Once upon a time there were three little sisters; and their names were
<ahref="http://example.com/elsie"class="sister"id="link1"><!-- Elsie --></a>,
<ahref="http://example.com/lacie"class="sister"id="link2">Lacie</a> and
<ahref="http://example.com/tillie"class="sister"id="link3">Tillie</a>;
and they lived at the bottom of a well.</p><pclass="story">...</p>
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'lxml')
print(soup.prettify()) #格式化源码,好看,也能将不完整的代码进行补全
print(soup.title.string) #获取title