Sign in to follow this  
Followers 0
Affe

winhttprequest Effeciency Help

1 post in this topic

I'm using a winhttprequest to poll a website for some data.

I have to do 2 separate requests to get the data I'm going for. First the initial request:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
;Post request
$oHTTP.Open("POST", "http://www.fluidorbit.co.uk/refine.php?query=Any+System+Partial+Matchs+Work&ore=Pyroxeres&ice=&regnom=" , False)
;OR Get request
;~ $oHTTP.Open("GET", "http://www.fluidorbit.co.uk/refine.php?query=Any+System+Partial+Matchs+Work&ore=Pyroxeres&ice=&regnom=" , False)
;Add user agent User-Agent=
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 AskTbMYC/3.8.0.12304 Firefox/3.6.6 ( .NET CLR 3.5.30729; .NET4.0E)")
;Add Referrer header
$oHTTP.SetRequestHeader("Referrer", "http://www.fluidorbit.co.uk/results.php?page=0&limit=1000&arrange=2&col=security")
;Add Content-Type
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
;Add Keep-Alive
$oHTTP.SetRequestHeader("Keep-Alive", "115")
;Add Connection
$oHTTP.SetRequestHeader("Connection", "keep-alive")
;Send POST request
$oHTTP.Send("query=Any+System+Partial+Matchs+Work&ore=Pyroxeres&ice=&regnom=")

This sets the data I'm looking for (data is in the .Send()) and keeps the connection alive. The above response does give me data, however, there is a second php page that will sort the results and give out x number of results. I then do a second query to sort the data:

;######### Begin sort ############
$oHTTP.Open("POST", "http://www.fluidorbit.co.uk/results.php?page=0&limit=1000&arrange=2&col=security" , False)
;OR Get request
;~ $oHTTP.Open("GET", "http://www.fluidorbit.co.uk/refine.php?query=Any+System+Partial+Matchs+Work&ore=Pyroxeres&ice=&regnom=" , False)
;Add user agent User-Agent=
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 AskTbMYC/3.8.0.12304 Firefox/3.6.6 ( .NET CLR 3.5.30729; .NET4.0E)")
;Referer=http://www.fluidorbit.co.uk/results.php?page=0&limit=100&arrange=1&col=solarSystemName
;POSTDATA=query=Any+System+Partial+Matchs+Work&ore=Pyroxeres&ice=&regnom=

;Add Referrer header
$oHTTP.SetRequestHeader("Referrer", "http://www.fluidorbit.co.uk/refine.php")
;Add Content-Type
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

$oHTTP.SetRequestHeader("Keep-Alive", "115")
$oHTTP.SetRequestHeader("Connection", "keep-alive")

$oHTTP.Send("page=0&limit=1000&arrange=2&col=security")

$oReceived = $oHTTP.ResponseText

Now my question here is this: Is there some kind of close ($oHTTP.Close()) that I should use? Is there a more efficient method of doing this (i.e. could I be doing this in one request)?


[center][/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0