Downloading Large Files -- Feedback?
mwt
michaeltaft at gmail.com
Sun Feb 12 21:42:23 EST 2006
So, I just put this little chunk to the test, which does give you
feedback about what's going on with a file download. Interesting that
with urlretrieve, you don't do all the file opening and closing stuff.
Works fine:
------------------
import urllib
def download_file(filename, URL):
f = urllib.urlretrieve(URL, filename, reporthook=my_report_hook)
def my_report_hook(block_count, block_size, total_size):
total_kb = total_size/1024
print "%d kb of %d kb downloaded" %(block_count *
(block_size/1024),total_kb )
if __name__ == "__main__":
download_file("test_zip.zip","http://blah.com/blah.zip")
More information about the Python-list
mailing list