|
-
Jan 17th, 2008, 01:16 PM
#1
Thread Starter
Member
Easiest way to get http header response from URL?
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.
-------------------------------
StupidMonkee
-
Jan 17th, 2008, 02:48 PM
#2
Re: Easiest way to get http header response from URL?
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
-
Jan 17th, 2008, 04:08 PM
#3
Thread Starter
Member
Re: Easiest way to get http header response from URL?
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).
-------------------------------
StupidMonkee
-
Jan 17th, 2008, 04:24 PM
#4
Re: Easiest way to get http header response from URL?
This is not something I'm too familiar with. Maybe someone else knows more and theres always MSDN.
-
Jan 17th, 2008, 04:39 PM
#5
Thread Starter
Member
Re: Easiest way to get http header response from URL?
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.
-------------------------------
StupidMonkee
-
Jan 18th, 2008, 04:27 PM
#6
Thread Starter
Member
Re: Easiest way to get http header response from URL?
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
-------------------------------
StupidMonkee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|