No Content-Length header, nor length property

zljubisic at zljubisic at
Wed Jul 8 08:15:43 CEST 2015

> Hello,
> urlopen returns an HttpResponse 
> object(  You need to call read() on the return value to get the page 
> content, or you could consider the getheader method to check for a Content-
> Length header.
> Hope that helps,
> Kev

Kev, did you mean?

import urllib.request

url = ''
site = urllib.request.urlopen(url)

print( site.getheader('Content-Length'))    # None
x =                            # No 'Content-Length' header

print('File size:', site.length)

I am still not getting anywhere. :(


More information about the Python-list mailing list