Script to download a file
#1
Brick 
Hi everyone,

I have this code
Code:
import urllib2

url = 'http://www.mywebsite.com/my.zip'

f = urllib2.urlopen(url)
data = f.read()
with open("my/location/code2.zip", "wb") as code:
code.write(data)

I am using a raspberry pi b+ the problem with this code is, if I'm not mistaken, is that it will download the whole file to ram and then write to disk. if the ram is not big enough it will fail. I have read somewhere that the file can be broken into chunks and written to disk without filling the ram up, crashing the pi.

Can someone please help with how to do this. Thanks in advance.
Reply
#2
https://docs.python.org/2/library/urllib...rlretrieve
Reply

Logout Mark Read Team Forum Stats Members Help
Script to download a file1