Get content length in HTTP request appropriately when using Python 3.

This commit is contained in:
Paul Romano 2014-08-06 21:06:17 -04:00
parent 3f0f68b4de
commit 3a3df8a8bb

View file

@ -32,7 +32,10 @@ for f in files:
req = urlopen(url)
# Get file size from header
file_size = int(req.info().getheaders('Content-Length')[0])
if sys.version_info[0] < 3:
file_size = int(req.info().getheaders('Content-Length')[0])
else:
file_size = req.length
downloaded = 0
# Check if file already downloaded