使用 FTPwalker 连接到 FTP 资源失败,并显示“名称或服务未知”

问题描述 投票:0回答:1

我正在尝试使用

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
有效。

python python-3.x ftp
1个回答
1
投票

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
,它采用“主机名”。

© www.soinside.com 2019 - 2024. All rights reserved.