Posts: 1,769
Threads: 410
Joined: Feb 2003
Is there a way to find out the date of a file on a website?
Posts: 12,087
Threads: 142
Joined: Dec 2002
If you can connect through ftp, use
Ftp.Dir:
Ftp f.Connect("www.aaa.com")
f.DirSet("public_html")
WIN32_FIND_DATA fd
if(f.Dir("file.htm" 0 &fd))
,DATE d.fromfiletime(fd.ftLastWriteTime)
,out d
,;or
,SYSTEMTIME st
,FileTimeToSystemTime &fd.ftLastWriteTime &st
,;...
Http protocol also allows to query file date, but not for all files.
Create new
member function Http.QueryInfo:
function# $file what str&info
;Retrieves specified header for file.
;what is one of inet.HTTP_QUERY_x flags. Use HTTP_QUERY_RAW_HEADERS_CRLF to retrieve all headers.
;EXAMPLES
;Http h.Connect("www.google.com")
;str s
;if(h.QueryInfo("about.html" HTTP_QUERY_RAW_HEADERS_CRLF s))
,;out s
;
;if(h.QueryInfo("about.html" HTTP_QUERY_LAST_MODIFIED s))
,;out s
;
;if(h.QueryInfo("about.html" HTTP_QUERY_LAST_MODIFIED|HTTP_QUERY_FLAG_SYSTEMTIME s))
,;SYSTEMTIME& st=+s
,;DATE d.fromsystemtime(st)
,;out d
def ERROR_INSUFFICIENT_BUFFER 122
int hr=HttpOpenRequest(m_hi 0 file 0 0 0 INTERNET_FLAG_RELOAD 0); if(!hr) goto e
if(!HttpSendRequest(hr 0 0 0 0)) goto e
_i=1000
if(!HttpQueryInfo(hr what info.all(_i) &_i 0))
,if(GetLastError!=ERROR_INSUFFICIENT_BUFFER) goto e
,if(!HttpQueryInfo(hr what info.all(_i) &_i 0)) goto e
info.fix(_i)
InternetCloseHandle hr
ret 1
;e
if(hr) InternetCloseHandle hr
Error