0

I am trying to download data from this FTP site "ftp://nais.ec.gc.ca" Python 2.7 I have tryied ofther FTP like "ftp://test.rebex.net/" and ftp://speedtest.tele2.net and they come up with the same error

I have the password and username and I know they work.

from ftplib import FTP

ftp = FTP("ftp://nais.ec.gc.ca")
ftp.login("Username","password")

The error I get is below:

[Errno 11001] getaddrinfo failed

I have also tried urllib function and it seems like it can login but i cant downloaded anything or access the correct directories.

1 Answers1

1

Your code looks like this:

ftp = FTP("ftp://nais.ec.gc.ca")

But in the documentation you'll find:

class ftplib.FTP(host='', ...
... When host is given, the method call connect(host) is made.

Thus, the first argument is a host name, not a URL. It shoud be just nais.ec.gc.ca not ftp://nais.ec.gc.ca

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172