[Tutor] How to update file?

Michael P. Reilly arcege@speakeasy.net
Sat, 12 Jan 2002 09:43:06 -0500


On Fri, Jan 11, 2002 at 08:52:52PM -0800, Danny Yoo wrote:
[Preceding snipped]
> Here's a small program that'll get the last-modified header if the web
> server supports it:
> 
> ###
> import httplib
> import urlparse
> 
> def getLastModifiedDate(url):
>     url_pieces = urlparse.urlparse(url)
>     base, path = url_pieces[1], url_pieces[2]     ## this can be
>                                                   ## improved...
>     conn = httplib.HTTPConnection(base)
>     conn.request("GET", path)
>     response = conn.getresponse()
>     return response.getheader('last-modified')
> ###

Additionally, web servers accept a HEAD request which will not
retreive the data, but just the headers, including the Last-Modified
(if sent at all).  If the file is large, it saves on work for the
server.

  -Arcege