pythonftp自動下載
發布時間: 2025-07-13 05:13:06
importftplib
path='c:/user/pcwuyu/desktop/1c0/'
l=[]
defls_filter(line):
ll=line.split()
ifll[5]=='Jan'andll[6]=='9'andll[7]>'14:30'andll[7]<'15:30':
ifll[8]!='.'andll[8]!='..':
l.append(ll[8])
returnll[8]
ftp=ftplib.FTP('127.0.0.1')
ftp.login('root','password')
ftp.cwd('/mnt/1c0')
ftp.set_pasv(False)
fs=ftp.retrlines('LIST',ls_filter)
foriinl:
ftp.retrbinary('RETR'+i,open(path+i,'wb').write)
ftp.quit()
一個簡單的例子,下載1月9日14:30~15:30的文件
熱點內容