How can I get the latest file from an FTP server?

I use Python to connect to an FTP server that contains a new list of data once per hour. I connect only once a day, and I want to upload only a new file to the directory. Is there any way to do this?

+3
source share
2 answers

Take a look at ftplib in the current version of python. You can see the function for processing the result of the LIST command that you want to publish for the directory, if you know that the last time you run a successful script, then you can analyze the result from the LIST and act on the new files in the directory. See ftplib for more information on how to do this. The relay function is what I expect to use.

-1
source

It seems that any system that automatically generates a file once an hour is likely to use an automatic naming scheme. Have you changed your mind by asking the server for a new file instead of a simpler analysis of file names?

, , , . , , .

+1

Source: https://habr.com/ru/post/1703585/


All Articles