三个函数
geturl() 请求的真是url
info() 请求的头信息
getcode()请求的返回代码sss
import urllib.request
url =
"http://www.tmall.com"
request = urllib.request.urlopen(url)
print(request)
print(
'###########################')
request_url = request.geturl()
print(request_url)
print(
'###########################')
request_info = request.info()
print(request_info)
print(
'###########################')
request_code = request.getcode()
print(request_code)
####################################################
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe D:/gui/caiji3.py
<http.client.HTTPResponse object at 0x024EF930> http请求对象
###########################
https://www.tmall.com/ 实际转发到这里了
###########################
Server: Tengine
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Date: Wed, 08 Feb 2017 02:59:12 GMT
Vary: Ali-Detector-Type
Cache-Control: max-age=0, s-maxage=60
X-Response-Time: 56
X-SID: wormholesource011186072011.eu13
X-ETag-Caculator: Tengine
ETag: W/"47ca19b830a2f3f65ba0ac9805ecfb75"
Via: cache6.l2ne1[0,200-0,H], cache54.l2ne1[0,0], cache2.cn209[0,200-0,H], cache7.cn209[0,0]
Age: 29
X-Cache: HIT TCP_MEM_HIT dirn:-2:-2
X-Swift-SaveTime: Wed, 08 Feb 2017 02:59:14 GMT
X-Swift-CacheTime: 58
Timing-Allow-Origin: *
EagleId: 7c707f4714865227813255042e
Strict-Transport-Security: max-age=31536000
###########################
200 http求情返回代码200正常
Process finished with exit code 0
转载请注明原文地址: https://ju.6miu.com/read-148832.html