PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Capture request/response HTTP headers with VBA

 
 
=?Utf-8?B?cDNwbHly?=
Guest
Posts: n/a
 
      8th Mar 2007
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
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      9th Mar 2007
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" <(E-Mail Removed)> wrote in message news:C05B4D8B-C4EF-4E53-AEF4-(E-Mail Removed)...
> 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



 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      9th Mar 2007
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" <(E-Mail Removed)> wrote in message
news:C05B4D8B-C4EF-4E53-AEF4-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?cDNwbHly?=
Guest
Posts: n/a
 
      9th Mar 2007
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" <(E-Mail Removed)> wrote in message news:C05B4D8B-C4EF-4E53-AEF4-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      9th Mar 2007
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" <(E-Mail Removed)> wrote in message news:50FFBD2E-CBB2-4089-9B07-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:C05B4D8B-C4EF-4E53-AEF4-(E-Mail Removed)...
> > > 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

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?cDNwbHly?=
Guest
Posts: n/a
 
      10th Mar 2007

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:newyorkny|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.com%2f&tw=14400&kv=9&ct=1173488669&cb=SiteID=msft&msppjph=1&ver=2.1.6000.1&rn=6Tw2AA7i&tpf=9bdebc94d476ff79d7a26ff9ace50a14 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



 
Reply With Quote
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      10th Mar 2007
If I tell you what's keeping you from attempting a denial of service
attack ?

Or sending lots of spam from hotmail.com?

 
Reply With Quote
 
=?Utf-8?B?cDNwbHly?=
Guest
Posts: n/a
 
      11th Mar 2007
hi

i am not into that sort of thing. in fact, i would not even know how to go
about it. additionally, i dont have the sort of time to waste on thngs like
that, as they are totally unproductive and dont produce profit.

i never heard of headers translating into 'spam'. but i'll behonst, i dont
like the term 'spam' and i dont like the attitude behind the original crybaby
that coined the term. i dont mind getting emails. i simply direct the general
bs mail to one address, and my coveted email for coveted purposes goes to
another.

i have been online for a long time, and never had a problem with unsolicited
emails - ever! any addy i have ever set up to get only personal email has
never once had an unsolicited email appear in it.

so i think people complain too much.

the only reasons people get unsolicited email would be they invite it!

1) having a common name that is easily generated by an auto email creator at
a major site (like aol)

2) having a paypal acct or stormpay acct, etc

3) putting the email addy anywhere on the web

4) giving an email addy to online business (banking, ebay, amazon, etc)

i think that about covers it.

but i you want to make sure you never get unsolicited email do the following:

pick an obscure name with 8 or more characters and never use it on the
internet - except to email your friends directly. as long as your friends
dont post your email addy to the net, that acct, reserved for only the mail
you want, will never get any unsolicited emails. at least i never have.

as for the other emails, you just have to accept that is part of the game on
the internet. but if you are clever, you can check all your email addys and
check for emails from addressees you want to hear from, like paypal, and
never even have to look at the rest.

i have so many email accts i have lost track, the free mail types, lfrom the
big names to the obscure. but i almost never actually go to the sites. i
have a program that gets the mail from all the free mail sites, for every
account i have, and gets the messages i want and i never see the rest.

'spam'? what's that?

the point is, things are better in a caveat emptor world, not the universe
of crybabies who want the government to make laws to protect them. the former
inspires innovation, the latter inspires nothing.




"(E-Mail Removed)" wrote:

> If I tell you what's keeping you from attempting a denial of service
> attack ?
>
> Or sending lots of spam from hotmail.com?
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP Web Request not corresponding with Response =?Utf-8?B?am9obm8=?= Microsoft Dot NET 0 11th Aug 2005 01:28 PM
Capturing headers from Request/Response octupul@gmail.com Microsoft Dot NET Framework 4 20th Jun 2005 10:14 AM
No access to Response Headers in HTTP Module? Shachar Tal Microsoft ASP .NET 0 20th Jun 2004 04:54 PM
Using HTTP Request and Response Alfred Sahayam Microsoft VB .NET 4 30th Mar 2004 09:02 AM
HTTP headers and Response.Redirect Sam Microsoft ASP .NET 6 8th Dec 2003 09:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:01 PM.