FTPwalker
遍历 ftp 目录,但是我无法连接。
当前通话正在使用:
walker = ftpwalker(server_name="hostname", url="ftp://username:password@hostname")
但是
walker.check_state()
给出:
>> walker.check_state()
Find leading...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 100, in check_state
self.path_not_exit(False)
File "/usr/lib/python3.4/site-packages/FTPwalker/runwalker.py", line 157, in path_not_exit
self.m_walker.Process_dispatcher(False)
File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 82, in Process_dispatcher
leadings = self.find_leading_dirs(self.root)
File "/usr/lib/python3.4/site-packages/FTPwalker/main_walker.py", line 37, in find_leading_dirs
files, dirs = self.run_object.find_leading(top)
File "/usr/lib/python3.4/site-packages/FTPwalker/traverse.py", line 75, in find_leading
conn = ftplib.FTP(self.server_url)
File "/usr/lib64/python3.4/ftplib.py", line 118, in __init__
self.connect(host)
File "/usr/lib64/python3.4/ftplib.py", line 153, in connect
source_address=self.source_address)
File "/usr/lib64/python3.4/socket.py", line 498, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib64/python3.4/socket.py", line 537, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
此处输入的
url
参数格式是否正确? ping hostname
有效。
FTPwalker 已死,请使用 FTPflow:
https://pypi.org/project/FTPflow/
旧答案:虽然该参数被错误地命名为
url
,但官方 FTPwalker 示例非常清楚地表明,该值实际上应该是一个普通的主机名:
from FTPwalker.runwalker import ftpwalker
walker = ftpwalker("Uniprot", "ftp.uniprot.org")
walker.check_state()
ftplib.FTP.connect
,它采用“主机名”。