impory urllib.request
response=urllib.request,urlopen('http://www.baidu.com') #请求站点获得一个httpResponse对象
print(response.reqd().decode('utf-8')) #返回网页内容
print(response.getheader('server')) #放回相应头重的server值
print(response.getheaders()) #以列表元祖对的形式返回相应头信息
print(response.fileno()) #返回文件描述符
print(response.version) #返回版本信息
print(response.status) #返回状态码200,404代表网页未找到
print(response.closed) #返回对象是否关闭(布尔值)
print(response.geturl()) #返回检索的url
print(response.info()) #返回网页的头信息
print(response.getcode()) #返回响应的http状态码
print(response.msg) #访问成功则返回ok
标签:返回,http,request,爬虫,笔记,urllib,print,2.21,response From: https://www.cnblogs.com/qiuyiweiqi/p/17140373.html