Incomplete filedownloads with python
I have the following python code:
import urllib2 DIR = '/home/aaron/Desktop/aaron-file/media/' LOC = DIR+'/'+bounty.title+'.mp3' u = urllib2.urlopen(url, 'rb') localFile = open(LOC, 'wb') localFile.write(u.read()) localFile.close() u.close()
It only creates small (about 60K of files) files that work correctly to stop suddenly. When I boot from firefox (copy and paste the same url) I get full size files (about 2MB).
I am running 32 bit ubuntu.
UPDATE: I believe this can be a problem when the length of the http content is inaccurate. How then will I ignore / set different lengths.
Thank.
+3
source to share
1 answer