How to use FTP in Python

import os
import ftplib
ftpServer = ftplib.FTP('ftp.swfwmd.state.fl.us', 'anonymous','you email address')
ftpServer.retrlines("LIST")
dirList = []
ftpServer.retrlines("LIST", dirList.append)
str = dirList[0].split(None, 8)
filename = str[-1].lstrip()
print("Dowloading File :: ",filename)
localPath = os.path.join(r"D:\ftp\dowloads", filename)
file = open(localPath, "wb")
ftpServer.retrbinary("RETR " + filename, file.write, 8*1024)
file.close()
print("Done !!")
print("Please check your downloded file : D:\ftp\dowloads")
Related Topics
- How to find hostname of a computer - Python
- How To Find IP Address In Python
- Send mail from Gmail account using Python
- Retrieving Email from a POP3 Server - Python
- Retrieving Web Pages with HTTP using Python
- How to open a web browser using Python
- Socket Programming in Python
- Multi threaded socket programming in Python