Easily download files from ftp servers!
Project description
This is ftp_download
Utilities to download files from ftp servers with Python.
Getting started:
ftp_download
is built upon Python's ftplib
, an it is a higher level interface made to allow downloads from ftp servers with simple and straightfoward code.
Here, everything starts with creating an ftplib.FTP
object:
from ftplib import FTP
ftp = FTP(
host = "ftp.examplehost.com",
user = "your_login_name",
passwd = "your_secure_password",
acct = "your_account_if_any"
)
Then you can start downloading. Here are some examples:
Download a single file
import ftp_download as ftpd
from ftplib import FTP
import os
# downloading /pub/R/CRANlogo.png
# from cran.r-project.org
ftp = FTP("cran.r-project.org")
rp = "/pub/R/CRANlogo.png"
lp = os.path.expanduser("~") # Download to user folder
ftpd.file(ftp, remote_file_path=rp, local_path=lp)
Notice that local_path
was specified, but if not, ftp_download
will save the files in {user}/Downloads/ftp_download
.
Download files from a folder
You can also give a path to a folder and download everything from there, notice that this is not recursive, and will get only the files.
import ftp_download as ftpd
from ftplib import FTP
import os
# downloading contents of /pub/R/web
# from cran.r-project.org
ftp = FTP("cran.r-project.org")
rp = "/pub/R/web"
lp = os.path.expanduser("~") # Download to user folder
ftpd.from_folder(ftp, remote_path=rp, local_path=lp)
It's also important to notice that currently, ftp_download
will not create a new folder on the local_path
specified.
Important configurations
ftp_download
will have a standard behavior that can be tweaked by changing the default values of ftp_download.Conf
:
import ftp_download as ftpd
# To stop printing event messages to stdout (default: True)
ftpd.Conf.verbose = False
# To change the standard download path (default: {user_folder}/Downloads/ftp_download)
ftpd.Conf.download_folder = "C:\\my\\custom\\path"
# To change the maximum amount of concurrent downloads (default: 20)
ftpd.Conf.set_max_concurrent_jobs(300)
Documentation
For more information, read the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ftp_download-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ecafafe671dc69198ab6f39a3178ba3caf8c1729027a96bd5398b449a119b0 |
|
MD5 | 5e5ea7b7605a23ec64cfd7c0728236cf |
|
BLAKE2b-256 | f3879d1e3c972398f3c0a083958f6bfecff8a0b1cced03dc7d38aadf21ea7b7b |