FoxPro Programming
Check to see if a website is up or down
This is topical - Is there a VFP function / utility to determine if we website is up or down? We have several down today it and would be good if we could determine when the go offline or comeback online. Thanks!
Sure you can do this with any HTTP client like wwHttp
:
DO wwhttp
loHttp = CREATEOBJECT("wwhttp")
loHttp.nTimeout = 2 && seconds
lcHTML = loHttp.Get(lcUrl)
IF (loHttp.nError # 0 OR ATC("search string",lcHtml) > 0)
? "Request failed: " + loHttp.cErrorMsg
return
ENDIF
Actually with wwHttp
there's a dedicated method:
llResult = loHttp.httpPing(2, lcUrl)
These are useful if you want to check whether a site is up before making calls inside of an application.
But for monitoring and notification etc., the the bigger issue is the scheduling and timing. Generally you should use a Web site monitor. There are many commercial online tools, or if you want to run something on your own without subscriptions, there's our West Wind Web Monitor.