[Tutor] To Specify a directory path to download
swati jarial
swati.jarial at gmail.com
Thu Jul 31 16:50:54 CEST 2008
Hello,
I am new to python this is the code I have written to download a file from
the internet and then send en email if any error occurs during download. I
just want know how to specify which folder to download my files. It
automatically downloads file to the directory where TEST1.txt sits...
import urllib
import traceback
import sys
import cStringIO
import ncbi_SendEmail
import os.path
import os
try:
for url in open("test1.txt"):
save_to = os.path.basename(url.strip())
urllib.urlretrieve(url.strip(),save_to)
except:
mssg = cStringIO.StringIO()
traceback.print_exc(file=mssg)
ncbi_SendEmail.email(mssg.getvalue());
mssg.close()
Thanks a Ton!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080731/6e90a6f8/attachment.htm>
More information about the Tutor
mailing list