No Content-Length header, nor length property
zljubisic at gmail.com
zljubisic at gmail.com
Wed Jul 8 02:15:43 EDT 2015
> Hello,
>
> urlopen returns an HttpResponse
> object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). 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 = 'http://radio.hrt.hr/prvi-program/aod/download/118467/'
site = urllib.request.urlopen(url)
print( site.getheader('Content-Length')) # None
x = site.read(1) # No 'Content-Length' header
print('File size:', site.length)
I am still not getting anywhere. :(
Regards.
More information about the Python-list
mailing list