WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: snowsnowsnow on April 04, 2020, 04:48:39 PM

Title: Quick way to validate a URL?
Post by: snowsnowsnow on April 04, 2020, 04:48:39 PM
I am in the planning states now for a script that will need to "validate" a series of URLs.

By "validate", I mean verity that the URL exists (i.e., that if I loaded it into a browser, it would work).  Obviously, I could just load it into a browser (via keystrokes) and see if it works, but I am hoping for something built-in to WB (e.g., in an extender).

Does that exist?
Title: Re: Quick way to validate a URL?
Post by: JTaylor on April 04, 2020, 06:17:38 PM
If you just want a way to verify URLs then this might help (can load from a file even though the web page doesn't mention that)...

         http://www.jtdata.com/jturl.html

doesn't really help if you need the script itself but thought I would throw it out there.  It is free.

Jim
Title: Re: Quick way to validate a URL?
Post by: stanl on April 05, 2020, 03:31:36 AM
A series of WinHttp.WinHttpRequest.5.1 requests and record either the status or response text. Could be a simple UDF and several examples of usage on Tech Database. Below is a quick way to check if your version of either WB or Windows supports:


Code (WINBATCH) Select


cURL='urltocheck'
oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", cURL, @FALSE)
oHTTP.Send()
oHTTP.WaitForResponse()
response = oHTTP.ResponseText