我正在尝试向我的应用程序添加一个组件,该组件从FTP位置获取文件以进行处理。 FTP服务器接受匿名登录,但在使用下面的代码时,我收到URLError 550 Access Denied。我搜索过各种类似的地方,甚至添加了密码管理器但没有成功。我继续得到550拒绝访问错误。
非常感谢任何协助。
代码段:
import urllib2
url = "ftp://<Removed>com/outgoing/test/b10349cq.zip"
response = urllib2.urlopen(url)
zip_file = open('C:\\tmp\\file.zip', "w")
zip_file.write(response.read())
zip_file.close()
错误:
Traceback (most recent call last):
File "C:\Documents and Settings\Administrator\Desktop\test.py", line 4, in <module>
response = urllib2.urlopen(url)
File "C:\Python27\lib\urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 404, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 422, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1394, in ftp_open
fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
File "C:\Python27\lib\urllib2.py", line 1416, in connect_ftp
persistent=False)
File "C:\Python27\lib\urllib.py", line 865, in __init__
self.init()
File "C:\Python27\lib\urllib.py", line 874, in init
self.ftp.cwd(dir)
File "C:\Python27\lib\ftplib.py", line 553, in cwd
return self.voidcmd(cmd)
File "C:\Python27\lib\ftplib.py", line 249, in voidcmd
return self.voidresp()
File "C:\Python27\lib\ftplib.py", line 224, in voidresp
resp = self.getresp()
File "C:\Python27\lib\ftplib.py", line 219, in getresp
raise error_perm, resp
URLError: urlopen error ftp error: 550 outgoing: Access is denied.