Python HEAD方法发送HTTP请求源码,pythonhead,之前的文章中有介绍过使用


之前的文章中有介绍过使用python 的GET方法发送HTTP请求,本文则是要使用HEAD方法来完成发送HTTP请求的操作。

另有GET/POST方法发送HTTP请求源码,请关注相关文章:
(1)Python用GET方法发送HTTP请求源码
(2)Python POST方法发送HTTP请求操作源码

>>> import httplib  >>> conn = httplib.HTTPConnection("www.python.org")  >>> conn.request("HEAD","/index.html")  >>> res = conn.getresponse()  >>> print res.status, res.reason  200 OK  >>> data = res.read()  >>> print len(data)  0 >>> data == ''  True #www.iplaypy.com

编橙之家文章,

评论关闭