getting files over ftp

Tom Hanks garbagecollector86 at hotmail.com
Wed Jan 28 19:08:14 EST 2004


heavens7s at hotmail.com (Joe) wrote in message news:<560d84ab.0401281049.18d377f3 at posting.google.com>...
> How can you grab files over an ftp connection using ftplib?  I can
> make the connection, browse to the directory, view directory, but
> can't copy over the files.
> 
> Thanks

def ftp_download(host, user, pswd, ftpdir, filename):
    """Downloads a single file from an FTP server"""
    ftp = ftplib.FTP()
    ftp.connect( host )
    ftp.login  ( user , pswd )
    ftp.cwd    ( ftpdir )

    f = file( filename , "wb" )
    ftp.retrbinary("RETR " + filename, f)



More information about the Python-list mailing list