Urllib2.urlopen (): getting content size

My python still works when work resolves it ...

I request loading the internal webUI using a script that uses urllib2.urlopen . I am wondering how you can get the page content size from each request. I can't seem to figure this out.

Thanks in advance,

Mhibin

+7
source share
1 answer
 print len(urlopen(url).read()) 

or

 >>> result = urllib2.urlopen('http://www.spiegel.de') >>> result.headers['content-length'] '181291' 
+18
source

All Articles