Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Return Redirect Redirected URL WinHttp.WinHttpRequest WinHttp WinHttpRequest
;Winbatch 2011B - loookup for redirected URL ;adopted from vbs script by Rob Vanderwoude ;Test based on URL he provided from his website ; ;PURPOSE: To return a redirected URL w/out actually visiting it ; ;NOTE: Rob puts out some pretty neats vbs scripts, and it ; is a good exercise to convert them to VB. ; In this case a gosub error handler is used which ; essentially ignores timeouts. ; I included his original code at the end of this script ; ;TESTS: Seems to be less than 100% reliable ;Stan Littlefield, Dec 9, 2012 ;================================================================================================ #DefineSubRoutine Lookup(cUrl,lQuiet,cRet ) IntControl(73,2,0,0,0) Option_UserAgentString = 0 Option_URL = 1 URLCodePage = 2 EscapePercentInURL = 3 Error_Timeout = 2147954402 :start oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") oHTTP.Open("GET", cURL, @FALSE) oHTTP.SetTimeouts(10000, 10000, 10000, 10000) oHTTP.Send("") oHTTP.WaitForResponse(10000) result = oHTTP.Option( Option_URL ) If result == cURL && lQuiet cRet=cRet:result Else cRet="Source URL: ":cURL:@CRLF:"Target URL: ":result EndIf If result == cURL && ! lQuiet cRet=cRet:"Redirected : ":cURL:@CRLF oHTTP=0 Lookup(result,lQuiet,cRet) EndIf oHTTP = 0 Return(cRet) :WBERRORHANDLER IntControl(73,2,0,0,0) oHTTP=0 Goto start #EndSubRoutine ;Test Message("",Lookup("http://robvanderwoude.com/wshexamples_l.html",1,"")) Exit ;=================================================================================
Article ID: W18209
Filename: Get Redirected URL.txt
File Created: 2012:12:10:10:11:34
Last Updated: 2012:12:10:10:11:34