using urllib with ftp?

J

John Salerno

I've tried this already and it seems to work, but I'm curious if it's
okay to use urllib when trying to access a url that begins with ftp://
instead of http://. Does this matter? It's only a text file, so it's not
really an FTP server I'm accessing, I don't think. I wasn't sure if
using ftplib would be overkill in this case, or if you even could use it
at all if you just want to get the page itself (the txt file).

Thanks.
 
F

Fredrik Lundh

John said:
I've tried this already and it seems to work, but I'm curious if it's
okay to use urllib when trying to access a url that begins with ftp://
instead of http://. Does this matter? It's only a text file, so it's not
really an FTP server I'm accessing, I don't think. I wasn't sure if
using ftplib would be overkill in this case, or if you even could use it
at all if you just want to get the page itself (the txt file).

from the urllib documentation:

Currently, only the following protocols are supported: HTTP,
(versions 0.9 and 1.0), Gopher (but not Gopher-+), FTP, and
local files.

</F>
 
J

John Salerno

Fredrik said:
from the urllib documentation:

Currently, only the following protocols are supported: HTTP,
(versions 0.9 and 1.0), Gopher (but not Gopher-+), FTP, and
local files.

Thanks. So the ftp:// is something different than actually using ftplib
to connect to an FTP server, right? I've used both urllib and ftplib, so
I know what they do, I just was a little unclear about whether they can
sometimes do each other's work as well.
 
F

Fredrik Lundh

John said:
Thanks. So the ftp:// is something different than actually using ftplib
to connect to an FTP server, right? I've used both urllib and ftplib, so
I know what they do, I just was a little unclear about whether they can
sometimes do each other's work as well.

urllib uses ftplib under the hood, but all you can do is to fetch files or directory
listings.

</F>
 
J

John Salerno

Fredrik said:
urllib uses ftplib under the hood, but all you can do is to fetch files or directory
listings.

Thanks! That makes perfect sense now that I know that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,206
Latest member
EpifaniaMc

Latest Threads

Top