0

i am getting really confused on how to connect to an ftp server while using a proxy in python. Some previous examples have confused me a lot as i am new to Python. Below are the variables i believe that will be needed in the code sample (the proxy is only a example for security reasons as is the username and password).

can someone please show me how to connect to the ftp server and download a file

the end goal is to use python to download files from this ftp server

import ftplib

proxy = {'http': "auth-proxy.xxxx.com:232", 'https': "auth-proxy.xxx.com:232"}

ftp_site = 'https://data.ftse.com'
username = 'xxxxxx'
password = 'yyyyyy'

#file path where the file is on the ftp server is below
filepath = 'https://data.ftse.com/filedownloadservlet?filename=eerf1808.csv&phyName=nXVi8I4q5Boy8gBpdpDg3jNBqfAZy0vfydRBHC3zs3qt6YadMA6xa9LM3QaIgx-g'
Zack
  • 339
  • 2
  • 12
  • What previous examples? Show us what did you try. The "code" you have posted is not really a code. – Martin Prikryl Aug 20 '22 at 20:28
  • @MartinPrikryl - i found this here - https://stackoverflow.com/questions/47167538/connecting-with-ftplib-via-ftp-proxy-in-python but it does not work for me because i dont have a proxy user and pass – Zack Aug 22 '22 at 08:22
  • Do you even know what kind of proxy you are connecting through? HTTP? SOCKS? FTP? Can you connect with any commandline/GUI FTP client? What is its configuration? Log file? – Martin Prikryl Aug 22 '22 at 08:47
  • @MartinPrikryl i have no idea im afraid. i know when i use the request module the proxy argument works but does not work when using ftplib as it doesn't take proxy as an argument. code is below self.response = requests.request("GET", url, headers=self.headers, auth=(self.key, self.secret), proxies=self.proxy).json() – Zack Aug 23 '22 at 14:29
  • So it's HTTP proxy? Would this help? [Setting up proxy with FTP with Python](https://stackoverflow.com/q/45472577/850848) – Martin Prikryl Aug 23 '22 at 16:30
  • @MartinPrikryl i saw this before but the problem i have (and maybe im being silly as i find all this proxy stuff confsuing) is i dont have a proxy username and password. i only have a ftp username and password. socks.set_default_proxy(socks.HTTP, proxy_host, proxy_port, username=proxy_username, password=proxy_password ) – Zack Aug 24 '22 at 14:04
  • The `username` and `password` arguments are optional. – Martin Prikryl Aug 24 '22 at 14:52
  • @MartinPrikryl I am getting this error now - socks.GeneralProxyError: Socket error: 403: Forbidden [*] Note: The HTTP proxy server may not be supported by PySocks (must be a CONNECT tunnel proxy) – Zack Aug 25 '22 at 10:54

0 Answers0