import urllib #(1)导入标准库
response=urllib.request.urlopen('http://jd.com') #(2)创建访问网页的对象
html=response.read() #(3)读出对象网页内容
print(html) #(4)输出网页内容(二进制)
html=html.decode('utf-8') #将二进制文件编译成utf-8文本文件
print(html)
print(response.geturl()) #获取网页地址
http://jd.com
print(response.getcode())#获取网页状态码:200表示正常,404表示不正常
200
print(response.getheaders())#获取服务器响应的标题