我试图使用Python 3的ftplib库从FTP服务器下载文件.
这是相关的代码 –
ftp = ftplib.FTP("ftp://library.daisy.org:21/User_****/Wise & Otherwise-22.zip")
ftp.login("xxxxx", "xxxxxxx")
ftp.cwd(path)
ftp.retrbinary("RETR " + filename, open(filename, 'wb').write)
ftp.quit()
当我尝试运行脚本时,出现以下错误 –
Traceback (most recent call last):
File "reader.py", line 604, in
sp.process_user_choice()
File "reader.py", line 72, in process_user_choice
self.download_books() File "reader.py", line 324, in download_books
ftp = ftplib.FTP(all_urls[response])
File "/usr/lib/python3.5/ftplib.py", line 118, in __init__
self.connect(host)
File "/usr/lib/python3.5/ftplib.py", line 153, in connect
source_address=self.source_address)
File "/usr/lib/python3.5/socket.py", line 694, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
一些笔记 –
>我有正确的URL和凭据
>我在代理服务器后面