def get_title(url):
s = requests.session()
response = request.urlopen(url)
html = response.read()
charset = chardet.detect(html)['encoding'] # 对该html进行编码的获取
result = s.get(url)
if (charset == "GB2312" or charset is None):
result.encoding = 'gbk'
else:
result.encoding = 'utf-8'
content = result.text
title = re.findall('(.*) ', content)[0]
return title