How to update file?

Steve Holden sholden at holdenweb.com
Sun Jan 13 15:06:14 EST 2002


"A" <printers at sendme.cz> wrote in ...
> Hello,
> I need to update a local file from a web server if the file on this web
> server is newer then that on my local hard disk.
> Do you have any idea how it can be done?
> thank you.

Shouldn't be too difficult: a standard web server will accept an
"If-Modified-Since" header and check the modification date of the requested
resource. If no modification has taken place since the date/time given in
the "If-Modified-Since" header the server will return a "304 Not Modified"
response, otherwise it will server the file content.

You should be able to use os.stat(path) to get the local timestamp for
inclusion in the "If-Modified-Since" header, and urllib to send an
appropriate request. I'm hoping you can work out the details for yourself
with this hint, but if not then say so.

Hope this helps.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list