Custom Search

Sunday, April 10, 2011

python how to download a file over http

from urllib import urlretrieve

def callback(blocknum, blocksize, totalsize):
print "Downloaded " + str((blocknum * blocksize)),
print " of ", totalsize

urlretrieve("http://www.example.com/my_file.pdf", "my_file.pdf", callback)
print "Download Complete"

No comments:

Post a Comment