I've written parser on python to download images from Internet:
import urllib2
for i in xrange(1,10):
r = urllib2.urlopen('http://example.com/'+str(i)+'.gif'))
f = open('C:\\' + str(i) + '.gif', 'w+')
f.write(r.read())
f.close()
Images can't be opened. Windows says 'Error while building image'. But I've found that every line of received file less on 1 byte than this line of original file, but both look similar. How to download correct file?
When working with windows you may need to put the "binary" flag b
in open...
f = open(r'C:\\'+str(i)+'.gif','wb')
On Windows you need to specify 'wb', not 'w+'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With