downloading files

Ehsan ehsan.khoddam at gmail.com
Fri Aug 3 14:48:40 EDT 2007


I foundd this code in ASPN  Python Cookbook for downloading files in
python but when it finished downloading files the files became
corrupted and didn't open, the files in internet havn't any problem:


def download(url,fileName):
	"""Copy the contents of a file from a given URL
	to a local file.
	"""
	import urllib
	webFile = urllib.urlopen(url)
	localFile = open(fileName, 'w')
	localFile.write(webFile.read())
	webFile.close()
	localFile.close()
download('http://www.2shared.com/download/1839752/cd520048/
xpersia14.3gp?tsid=20070803-143313-49566ea2', 'xpersia4.3gp' )




More information about the Python-list mailing list