from urllib.request import urlopen
url = 'http://www.baidu.com'
resp = urlopen(url)
with open('mybaidu.html', mode='wb') as f:
f.write(resp.read())
print('over')
urllib:该库可操作URL
urllib.request:打开/读取url
urllib.error:有urllib.request抛出的异常
urllib.parse:解析URL
urllib.robotparse:解析robots.txt文件
urlopen(url):打开url地址
mybaidu.html效果