Python 获取页面title

#!/usr/bin/python
#coding=utf-8

#urllib2是python自带的模块,在python3.x中被改为urllib.request
import urllib.request
import re

page = urllib.request.urlopen('http://www.baidu.com')
html = page.read().decode('utf-8')
# Python3 findall数据类型用bytes类型
# or html=urllib.urlopen(url).read()

title=re.findall('<title>(.+)</title>',html)
print (title)