In the question here we learn how to get files using FTP in python. The answer is what I have in my code, and also as follows:
import shutil
import urllib.request as request
from contextlib import closing
with closing(request.urlopen('ftp://server/path/to/file')) as r:
with open('file', 'wb') as f:
shutil.copyfileobj(r, f)
How do I go about now saving these files locally? This path/to/file
has a bunch of directories and files within nested directories. I'd ideally like to download the root directory and have all the files and folders within.
As I am new to both Python and FTP, I am not 100% sure that my question is as clear as possible. Please do not hesitate to ask for clarification in the comments, thanks!