Código Python:
Ver originalfrom ftplib import FTP
class ftpFac():
def __init__(self,host,user,pwd):
self.host = host
self.user = user
self.pwd = pwd
def open(self):
self.ftp = FTP(self.host)
self.ftp.login(self.user, self.pwd)
def download(self, server_directory, remote_file, local_file=""):
if not local_file:
local_file = remote_file
self.open()
self.ftp.cwd(server_directory)
self.ftp.retrbinary("RETR " + remote_file, open(local_file, 'wb').write)
def close(self):
self.ftp.quit()
f = ftpFac("host_here", "username_here", "password_here")
f.open()
f.download("path", "filename")
f.close()