all Python 3urllib.requestterm
urllib.request.FTPHandler
protocol handlers
The handler for ftp:// URLs: it takes the login and password from the address itself and logs in anonymously without them.
Syntax
urllib.request.FTPHandler()
The password in 'ftp://user:pass@host/path' stays in the URL — in logs and error messages — and FTP itself sends it in clear text. A new connection is opened for every request; CacheFTPHandler reuses them. urllib cannot do FTPS (FTP over TLS) — use ftplib.FTP_TLS.
Examples
import urllib.request
req = urllib.request.Request('ftp://user:secret@ftp.example.com/pub/file.txt')
print(req.type, req.host, req.selector)
# → ftp user:secret@ftp.example.com /pub/file.txt
See also
Open in the full glossarydocs.python.orgReport an inaccuracy