urllib.request.urlopen("ftp://username:password@ftpserver/file" returns <urlopen error [Errno -2] Name or service not known> if password contains '#'
Could someone let me know if there are any known issues? or workaround or fix available for this
urllib.request.urlopen("ftp://username:password@ftpserver/file" returns <urlopen error [Errno -2] Name or service not known> if password contains '#'
Could someone let me know if there are any known issues? or workaround or fix available for this
The requests library doesn't usually like ftp:// type links.
To download a file from an FTP server I would recommend using urlretrieve.
Try something like the following:
import urllib.request
urllib.request.urlretrieve('ftp://server/path/to/file', 'file')
# if you need to pass credentials try
urllib.request.urlretrieve('ftp://username:password@server/path/to/file', 'file')
To get around the # issue, we can use URL encoding by changing to the characters %23 which should be recognized as #.
Ex:mypassword%23 will be recognized as mypassword#