Size of a remote URL

Diez B. Roggisch deetsNOSPAM at web.de
Mon Aug 30 16:59:59 EDT 2004


First of all: post working code, not some snipplet that clearly isn't
capable of running due to syntactic and semantic errors.

This is what I made of your code:

from urllib2 import *
linklisttype = ["http://www.ecs.soton.ac.uk/~harnad/Temp/Ariadne-RAE.doc"] *
4

file_sizes = []
for y in linklisttype:
    temp = urlopen(y)
    print temp
    temp2 = temp.info()
    print temp2
    temp3 = temp2.getheader("Content-Length")
    print temp3
    file_sizes.append(temp3)

print file_sizes

This is the result:

632832
<addinfourl at 1079834668 whose fp = <socket._fileobject object at
0x401f35dc>>
Date: Mon, 30 Aug 2004 20:57:49 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
Last-Modified: Sun, 20 Apr 2003 15:19:42 GMT
ETag: "f10f630-9a800-3ea2ba8e"
Accept-Ranges: bytes
Content-Length: 632832
Connection: close
Content-Type: application/msword

632832

<snip>

['632832', '632832', '632832', '632832']

Works perfect.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list