三个函数 geturl() 请求的真是url info() 请求的头信息 getcode()请求的返回代码sssimport 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
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态