Created
August 6, 2021 04:44
-
-
Save user0able/e53bfd805e26fcf045f5ad629c54b5c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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