How I can get the file size from a url ?

regisma

Developer
Sep 21, 2014
282
0
0
Hi,

Finally I have found this way:

request = urllib2.Request(url)

response = urllib2.urlopen(request, timeout=10)

try: urlcontent = int(response.headers['Content-Length'])
except: urlcontent = 0

megs = urlcontent / (1024 * 1024)

Regis