I am trying to add a component to my application that grabs a file from an FTP location for processing. The FTP server accepts anonymous logins, but when using the code below, I receive a URLError 550 Access Denied. I have searched various locations for something similar, and have even added a password manager with no success. I continue to get the 550 access denied error.
Would appreciate any assistance.
Code Snippet:
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()
Error:
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.