curl-and-python

Re: Pycurl and FTP

From: James Webber <jamestwebber_at_gmail.com>
Date: Fri, 11 Jun 2010 09:31:23 -0400

It's as simple as setting the pycurl URL to the FTP directory, and getting
that page. I just tried this:

>>> import pycurl
>>> crl = pycurl.Curl()
>>> crl.setopt(pycurl.URL, r'ftp://ftp.ncbi.nih.gov/refseq/release/')
>>> crl.perform()
-r--r--r-- 1 ftp anonymous 4444 Sep 16 2004 README
dr-xr-xr-x 2 ftp anonymous 761856 May 19 14:10 complete
dr-xr-xr-x 2 ftp anonymous 24576 May 19 14:12 fungi
dr-xr-xr-x 2 ftp anonymous 49152 May 19 13:13 invertebrate
dr-xr-xr-x 2 ftp anonymous 438272 May 19 12:55 microbial
dr-xr-xr-x 2 ftp anonymous 4096 May 19 12:29 mitochondrion
dr-xr-xr-x 2 ftp anonymous 12288 May 19 12:28 plant
dr-xr-xr-x 2 ftp anonymous 4096 May 19 14:11 plasmid
dr-xr-xr-x 2 ftp anonymous 4096 May 19 12:55 plastid
dr-xr-xr-x 2 ftp anonymous 16384 May 19 13:09 protozoa
dr-xr-xr-x 3 ftp anonymous 4096 May 19 14:12 release-catalog
dr-xr-xr-x 3 ftp anonymous 4096 May 19 14:26 release-notes
dr-xr-xr-x 3 ftp anonymous 4096 May 19 14:12 release-statistics
dr-xr-xr-x 2 ftp anonymous 36864 May 19 13:07 vertebrate_mammalian
dr-xr-xr-x 2 ftp anonymous 8192 May 19 12:31 vertebrate_other
dr-xr-xr-x 2 ftp anonymous 4096 May 19 13:08 viral
>>>

Of course, you'd have to parse that result, but that shouldn't be too hard.

- James

On Fri, Jun 11, 2010 at 5:22 AM, MARTIN Oliver <o.martin_at_wanadoo.fr> wrote:

> Hi,
>
> I'm trying using Pycurl to connect to FTP.
>
> I need to list an FTP directory, dowload files from this directory and
> erase files after download.
>
> I don't know how to get the content of the directory in a list.
>
> Does anyone can help me please? Or are there somewhere some source code
> that could help me ?
>
> Thanks,
>
> Olivier
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2010-06-11