urllib模拟浏览器访问网页地址,拿到服务器响应的数据html页面
import urllib.request as ur
ret0 = ur.urlopen('https://edu.csdn.net/')#response对象
ret = ur.urlopen('https://edu.csdn.net/').read()#读取网页内容
print(ret)#字节对象
with open('edu.html','wb') as f:#写入本地文件
f.write(ret)
打开本地的edu.html与https://edu.csdn.net/一致