Jump to content

Get Request headers


Recommended Posts

;;Instantiate a WinHttpRequest object
Local $WinHttpReq = ObjCreate("winhttp.winhttprequest.5.1")
Local $url = "https://www.google.com/"
;;Initialize an HTTP request.
$WinHttpReq.Open("GET", $url, false)
$WinHttpReq.send()
;;Get all response headers
Local $Get_Header = $WinHttpReq.GetAllResponseHeaders()
Sleep(500)
MsgBox(0, "", $Get_Header)

It returns Response headers but how I capture/get Request headers?

Link to comment
Share on other sites

@Nine

Using $WinHttpReq.ResponseText with the original site I can see the lots of text & the ID number i am looking.
but the problem is I can search the ID from the text but don't know how to extract the "number (111-1111111-111111)" after that.

something like this.....

bbbbbbbb 6666-666666-666, bbbbbbb bbbbb bbbbbb
bbb { bb: 6666-666-666,  bbbbb } bbbbbb bbbbbbb
bbbbb {  ID: 111-1111111-111111,  bbbbbbbbb }bbbbbbb
bbbbbbbbbb bbb8888-8888-888bbb bbbbbbbbbbbb bbb

 

Edited by jugador
Link to comment
Share on other sites

If the string you are looking is in ResponseText then it is not a header, it is in the body of the document.  As you can see, ResponseText always start with <!DOCTYPE html...> but headers come before. So if you want to extract this ID.  I suggest you use SRE to get it or IE udf as this should be embedded in a starting tag, right ?

Link to comment
Share on other sites

Thanks to @mikell solution  ,I manage to extract the number.

Local $sText = "bbbbbbbb 6666-666666-666, bbbbbbb bbbbb bbbbbb" & _
"bbb { ID: 6666-666-666,  bbbbb } bbbbbb bbbbbbb" & _
"bbbbb {  ID: 111-1111111-111111,  bbbbbbbbb }bbbbbbb" & _
"bbbbbbbbbb bbb8888-8888-888bbb bbbbbbbbbbbb bbb"
MsgBox(0, "", $sText)

Local $teams = StringRegExp($sText, '(?s)ID:(.*?),', 3)
For $i = 0 to UBound($teams)-1
    MsgBox(0, "", $teams[$i])
Next

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...