Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Capture request/response HTTP headers with VBA

hi

was wondering if anyone knows how to do this. there is some code in VB5 that
supposedly gets this information, but it wont work with VBA

http://www.planet-source-code.com/vb...p%2FC117001102

all i need is the code that logs the GET information.

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Capture request/response HTTP headers with VBA

Look for xmlhttp - plenty of code examples online.

Function GetHeader(sURL As String) As String

Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")

oXHTTP.Open "HEAD", sURL, False
oXHTTP.send

GetHeader = oXHTTP.getAllResponseHeaders()

End Function

--
Tim Williams
Palo Alto, CA


"p3plyr" wrote in message ...
hi

was wondering if anyone knows how to do this. there is some code in VB5 that
supposedly gets this information, but it wont work with VBA

http://www.planet-source-code.com/vb...p%2FC117001102

all i need is the code that logs the GET information.

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Capture request/response HTTP headers with VBA

Depending on what you want to retrieve, amend this:

'Need a referenece to "Microsoft WinHTTP Services"
Private Sub CommandButton1_Click()
Dim HTTPobj As WinHttp.WinHttpRequest

Const WHICHURL As String = "http://www.Google.co.uk"

Set HTTPobj = New WinHttp.WinHttpRequest

With HTTPobj
.Open "GET", WHICHURL
.Send
MsgBox .ResponseText
End With

End Sub

NickHK

"p3plyr" wrote in message
...
hi

was wondering if anyone knows how to do this. there is some code in VB5

that
supposedly gets this information, but it wont work with VBA


http://www.planet-source-code.com/vb...p%2FC117001102

all i need is the code that logs the GET information.

thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Capture request/response HTTP headers with VBA

Tim, thanks for taking the time to reply. i really appreciate it!

my vb skills are somewhat limited. can you give me an example of how i can
call on that function you posted so that it will return the data such as i
just posted in the reply to Nick above?

thanks again





"Tim Williams" wrote:

Look for xmlhttp - plenty of code examples online.

Function GetHeader(sURL As String) As String

Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")

oXHTTP.Open "HEAD", sURL, False
oXHTTP.send

GetHeader = oXHTTP.getAllResponseHeaders()

End Function

--
Tim Williams
Palo Alto, CA


"p3plyr" wrote in message ...
hi

was wondering if anyone knows how to do this. there is some code in VB5 that
supposedly gets this information, but it wont work with VBA

http://www.planet-source-code.com/vb...p%2FC117001102

all i need is the code that logs the GET information.

thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Capture request/response HTTP headers with VBA

dim c as range

for each c in thisworkbook.sheets("Sheet1").range("A2:A50")
if c.value<"" then c.offset(0,1).value=GetHeader(c.value)
next c

Assuming A2:A50 is a range containing URL's.

--
Tim Williams
Palo Alto, CA


"p3plyr" wrote in message ...
Tim, thanks for taking the time to reply. i really appreciate it!

my vb skills are somewhat limited. can you give me an example of how i can
call on that function you posted so that it will return the data such as i
just posted in the reply to Nick above?

thanks again





"Tim Williams" wrote:

Look for xmlhttp - plenty of code examples online.

Function GetHeader(sURL As String) As String

Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")

oXHTTP.Open "HEAD", sURL, False
oXHTTP.send

GetHeader = oXHTTP.getAllResponseHeaders()

End Function

--
Tim Williams
Palo Alto, CA


"p3plyr" wrote in message ...
hi

was wondering if anyone knows how to do this. there is some code in VB5 that
supposedly gets this information, but it wont work with VBA

http://www.planet-source-code.com/vb...p%2FC117001102

all i need is the code that logs the GET information.

thanks








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Capture request/response HTTP headers with VBA


Hi again

and thanks again

ok, well, you make it look so easy :)

i must be doing somethng wrong here.
This is what i've got:

Code:
Function GetHeader(sURL As String) As String
Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "HEAD", sURL, False
oXHTTP.send
GetHeader = oXHTTP.getAllResponseHeaders()
Dim c As Range
End Function
'----------------------------------------------------------
Sub test()
Set ie = CreateObject("InternetExplorer.Application")
With ie
..Visible = True
..Navigate "http://my.msn.com"
Do Until .ReadyState = 4: DoEvents: Loop
Do While ie.busy: DoEvents: Loop
End With
For Each c In ThisWorkbook.Sheets("Sheet1").Range("A2:A50")
If c.Value < "" Then c.Offset(0, 1).Value = GetHeader(c.Value)
Next c
End Sub
the range A2:A50 is still empty.

basically, and i did not make it that clear, what i am looking for is a
routine that will record all the header action, as it occurs during
navigation.

for example, if i navigate to http://my.msn.com, just typing that one URL in
my address bar and hitting enter on my keyboard, i get all this header
activity (courtesy of DebugBar 4.2)

---------------------------------
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
application/x-shockwave-flash, */*
Referer: http://www.msn.com/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: my.msn.com
Connection: Keep-Alive
Cookie: MC1=V=3&GUID=1b9fd9574b9a4952a6148750072c065c; mh=MSFT;
CULTURE=EN-US; ushpsvr=M:5|F:5|T:5|E:5|D:blu|W:F;
ushpcli=0|H.0.1|G.0.1|Z.0.1|R.0.1.cap|C.0.1.lg:new yorkny|L.0.1.LN:WNBC;
ushpwea=wc:USNY0996; ushppr=H:1:070308

HTTP/1.1 302 Found
nnCoection: close
Date: Sat, 10 Mar 2007 01:04:29 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
P3P:CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
X-AspNet-Version: 1.1.4322
Location:
http://login.live.com/login.srf?lc=1...a26ff9ace50a14
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/html; charset=utf-8
Content-Length: 351

GET
/login.srf?lc=1033&id=6528&ru=http%3a%2f%2fmy.msn.c om%2f&tw=14400&kv=9&ct=1173488669&cb=SiteID=msft&m sppjph=1&ver=2.1.6000.1&rn=6Tw2AA7i&tpf=9bdebc94d4 76ff79d7a26ff9ace50a14 HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
application/x-shockwave-flash, */*
Referer: http://www.msn.com/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: login.live.com
Connection: Keep-Alive

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: close
Date: Sat, 10 Mar 2007 01:04:30 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
Content-Encoding: gzip
Expires: Sat, 10 Mar 2007 01:03:30 GMT
Vary: Accept-Encoding
Server: Microsoft-IIS/6.0
PPServer: PPV: 30 H: BAYPPLOG2B05 V: 0
X-Powered-By: ASP.NET
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
Set-Cookie: MSPRequ=lt=1173488670&co=1&id=6528; path=/;version=1
Set-Cookie: MSPOK=uuid-79e09a36-40d4-4158-a4f1-3e859545e560;
domain=login.live.com;path=/;version=1

--------------------------------------------------


so what i am trying to do is have my vba routine navigate to, in this
example, my.msn.com, and then some how be picking up all that header detail
and either placing it on the spreadsheet or sending it to a tet file for
future analysis.

so conceivably the code would look something like this:

Code:
Function GetHeader(sURL As String) As String
Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "HEAD", sURL, False
oXHTTP.send
GetHeader = oXHTTP.getAllResponseHeaders()
Dim c As Range
End Function
'----------------------------------------------------------
Sub test()

'begin recording all headers and write to spreadsheeet or text file

Set ie = CreateObject("InternetExplorer.Application")
With ie
..Visible = True
..Navigate "http://my.msn.com"
Do Until .ReadyState = 4: DoEvents: Loop
Do While ie.busy: DoEvents: Loop
End With
' stop recording of headers

End Sub
so when i go to take a look at all the headers recorded in the process, i
finally can get to the text string i need.

thanks again



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Capture request/response HTTP headers with VBA

If I tell you what's keeping you from attempting a denial of service
attack ?

Or sending lots of spam from hotmail.com?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I transform a word response to a numeric response? kanegaro Excel Discussion (Misc queries) 0 January 11th 08 05:08 PM
How do I set up a daily call out response response register? Pule Excel Worksheet Functions 1 October 7th 07 01:34 PM
start http://..... vs hyperlink http://..... ton de w Excel Discussion (Misc queries) 0 May 4th 07 01:42 PM
Importing XML data from http request Pau Larsen Excel Discussion (Misc queries) 0 December 2nd 04 02:01 PM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"