I need to extract a file from an FTP server using Python. I have tried to use ftplib, but it does not seem to work when using a proxy. I have also tried using the ftp-proxy-client package it does not seem to work either.
I have used these credentials.
ftp_adress = "XXX.XXX.XXX.XX"
ftp_user = "FTP_user"
ftp_password = "FTP_password"
ftp_port = "XXX"
ftp_path = "path"
file_name = "file_name.xlsx"
local_path = "local_path/file_name.xlsx"
proxy = "proxy_name.com"
proxy_port = "XXXX"
The code I have tried is:
from ftp_proxy_client import FtpProxy
ftp_proxy = FtpProxy(host=proxy, port=proxy_port)
ftp_client = ftp_proxy.connect('ftp_adress',
port=ftp_port,
login=ftp_user,
password=ftp_password)
fp = ftp_client.download(path=f"{ftp_path}/{file_name}")
with open(local_path, 'wb') as file:
file.write(fp.read())
But I end up with this error:
FtpProxyError: Failed connecting to proxy server