Is there a simple way to feed in a URL and just get the response? 301, 200, 404 etc?
I have seen the ICMP stuff but I would like to make it as small and simple as possible. something along the lines of wget.
Printable View
Is there a simple way to feed in a URL and just get the response? 301, 200, 404 etc?
I have seen the ICMP stuff but I would like to make it as small and simple as possible. something along the lines of wget.
Is this good for you? (win2k+)
Code:Option Explicit
'Requires a reference to Microsoft WinHTTP Services
Private Sub Form_Load()
Dim WebLink As WinHttp.WinHttpRequest
Set WebLink = New WinHttp.WinHttpRequest
WebLink.Open "GET", "http://www.martind1.com/"
WebLink.Send
Debug.Print WebLink.GetAllResponseHeaders
'or
Debug.Print WebLink.GetResponseHeader("Content-Type")
Set WebLink = Nothing
End Sub
Yes this looks real good. It will at least allow me to know that the pages are live (200) status.
however I can't seem to determine if there was a redirect in there (301 code)
use for example http://www.cnet.com/news
it should redirect to http://news.redir.com.com/news
but i only get the last result (the 200).
This is not something I'm too familiar with. Maybe someone else knows more and theres always MSDN.
Thanks though. Yours is definitely a good start and very usefull for me.
I have a feeling that i might be able to use the ResponseStream to capture it but I am not quite sure how.
So anyone out there ... I am still listening.
They key solution I now need is something that captures 301 redirects before hitting a 200 success page.
Found it!
I just had to turn off the enable redirects and ... success!
Code:Dim WebLink As WinHttp.WinHttpRequest
Set WebLink = New WinHttp.WinHttpRequest
WebLink.Option(WinHttpRequestOption_EnableRedirects) = False
WebLink.Open "GET", "http://www.cnet.com/news"
WebLink.Send
MsgBox WebLink.Status