Retrieve file by FTP (using urllib)

Oleg Broytmann phd at
Fri Feb 11 11:45:33 CET 2000


   What am I doing wrong? And how to use urllib to get files by FTP?

import urllib

   fname, headers = urllib.urlretrieve("")
   print fname
   print headers

except Exception, msg:
   print msg
   import traceback; traceback.print_exc()

[Errno ftp error] 426 Transmission failure: not a directory
Traceback (innermost last):
  File "./xxx", line 7, in ?
    fname, headers =
  File "/usr/local/lib/python1.5/", line 66, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook)
  File "/usr/local/lib/python1.5/", line 184, in retrieve
    fp =
  File "/usr/local/lib/python1.5/", line 157, in open
    return getattr(self, name)(url)
  File "/usr/local/lib/python1.5/", line 379, in open_ftp
    (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
  File "/usr/local/lib/python1.5/", line 582, in retrfile
  File "/usr/local/lib/python1.5/", line 397, in nlst
    self.retrlines(cmd, files.append)
  File "/usr/local/lib/python1.5/", line 359, in retrlines
    return self.voidresp()
  File "/usr/local/lib/python1.5/", line 208, in voidresp
    resp = self.getresp()
  File "/usr/local/lib/python1.5/", line 199, in getresp
    raise error_temp, resp
IOError: [Errno ftp error] 426 Transmission failure: not a directory

    Oleg Broytmann      Foundation for Effective Policies      phd at
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-list mailing list