Size of a remote URL

Peter Kleiweg in.aqua.scribis at nl.invalid
Mon Aug 30 15:53:28 EDT 2004


Justin schreef:

> Ok so the problem is that my code is not requesting the headers
> properly.  I get back.  Just that.  I don't know what the difference is
> between the IE request and mine
>
> \ Date: Mon, 30 Aug 2004 19:36:20 GMT
> Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.12
> OpenSSL/0.9.6b DAV/
> 1.0.3 PHP/4.3.2 mod_perl/1.26
> Connection: close
> Content-Type: text/html; charset=iso-8859-1
>
>
> My code:
> for y in linklisttype:
> w = urlopen(y)
> z = w.info()
> x = z.getheader("Content-Length")
> file_sizes.append(x)
> Is there a better method for getting headers than urlopen?

This works:

import httplib
conn = httplib.HTTPConnection("www.ecs.soton.ac.uk")
conn.request("HEAD", "/~harnad/Temp/Ariadne-RAE.doc")
r1 = conn.getresponse()
r1.getheader('Content-length')



-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/~kleiweg/ls.html




More information about the Python-list mailing list