Skip to content

Instantly share code, notes, and snippets.

@user0able
Created August 6, 2021 04:44
Show Gist options
  • Save user0able/e53bfd805e26fcf045f5ad629c54b5c6 to your computer and use it in GitHub Desktop.
Save user0able/e53bfd805e26fcf045f5ad629c54b5c6 to your computer and use it in GitHub Desktop.
import ftplib
import time
USER = 'xxx'
PASSWORD = 'xxx'
HOST = '207.38.86.xx'
ROUTE = 'temporal'
def ftp_connect(HOST, USER, PASSWORD, ROUTE):
ftp = ftplib.FTP(
host=HOST,
user=USER,
passwd=PASSWORD
)
ftp.cwd(ROUTE)
files = ftp.nlst()
for file in files:
# download file:
with open(file, 'wb') as temp_file:
ftp.retrbinary('RETR %s' % file, temp_file.write)
ftp.delete(file)
ftp.quit()
while True:
ftp_connect(
HOST,
USER,
PASSWORD,
ROUTE
)
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment