I'm trying to use a python script (found here: eat-gorila) that is supposed to download multiple images from a website. I'm able to run the script, but the downloaded images are truncated. This is how the downloaded images appears when downloaded: Howtheimageappears
And this is how is the url this image was downloaded from: image
Maybe the script doesn't give enough time to download the images... Can you suggest me how to fix it? The code is the following (I removed other "volumes", leaving only one as an example):
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import urllib2
from datetime import datetime
volumes = [{'url':'http://ift.tt/1zuTxfP',
'start':1,
'end': 372,
'index': 1},]
for v in volumes:
os.mkdir(os.path.join(os.getcwd(), 'gorila_volume%d' % (v['index'])))
for i in range(v['start'], v['end'] + 1):
imageurl = v['url'].format(i, fill='0', align='right')
print imageurl
u = urllib2.urlopen(imageurl)
localfile = open(os.path.join(os.getcwd(), 'gorila_volume%d' % (v['index']), 'image%03d.jpg' % (i)), 'w')
localfile.write(u.read())
localfile.close()
print "done at %s" % datetime.now()
Any help is appreciated. Thank you!
Aucun commentaire:
Enregistrer un commentaire