45 |
def getLastModifiedTime(url): |
def getLastModifiedTime(url): |
46 |
"""Makes a request for url and returns the Last-Modified header""" |
"""Makes a request for url and returns the Last-Modified header""" |
47 |
|
|
48 |
request = urllib2.Request2(url) |
request = Request2(url) |
49 |
opener = urllib2.build_opener() |
opener = urllib2.build_opener() |
50 |
data = opener.open(request) |
data = opener.open(request) |
51 |
return(data.headers.dict["last-modified"]) |
return(data.headers.dict["last-modified"]) |
54 |
def URLisNewerThan(url, epoch): |
def URLisNewerThan(url, epoch): |
55 |
"""Makes an IMS request for url with epoch as the modification time and returns if URL has changed""" |
"""Makes an IMS request for url with epoch as the modification time and returns if URL has changed""" |
56 |
|
|
57 |
request = urllib2.Request2(url) |
request = Request2(url) |
58 |
request.add_header('If-Modified-Since', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(epoch))) |
request.add_header('If-Modified-Since', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(epoch))) |
59 |
opener = urllib2.build_opener(DefaultErrorHandler()) |
opener = urllib2.build_opener(DefaultErrorHandler()) |
60 |
data = opener.open(request) |
data = opener.open(request) |