from urllib import request
import re
def main():
url = 'http://www.baidu.com'
response = request.urlopen(url=url)
html = response.read()#.decode('utf8')
# p = '<title>(.*)</title>'
# mo = re.search(p,html)
if html:
# print((mo.groups(0)))
with open('index.html','wb') as f:
f.write(html)
else:
print('没有找到')
if __name__ == '__main__':
main()