On Wed, May 7, 2008 at 5:41 PM, Anand Balachandran Pillai
<[EMAIL PROTECTED]> wrote:
> Make a HEAD request. Here is one way of doing it, using urllib2.
>
>  class HeadRequest(urllib2.Request):
>     """ A request class which performs a HEAD request """
>
>     def get_method(self):
>         return 'HEAD'
>
>  req = HeadRequest(url)
>  f = urllib2.urlopen(req)
>  headers = dict(f.headers)
>  print headers.get('content-length',-1)'

Here is another way.

import httplib

conn = httplib.HTTPConnection(host)
conn.request('HEAD', path)
print conn.getresponse().getheader('Content-Type')
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to