Jump to content
Sign in to follow this  
TomCat

Possible to change InetGet() user-agent ?

Recommended Posts

TomCat

Hi some Question, in _INetGetSource it is possible to change user-agent in something else than Autoit. Is their any way to do the same with InetGet ?

Share this post


Link to post
Share on other sites
Armand

Not as far as i know.... but you can.

A. use an IE object and change the user-agent in there.

B. write the entire TCP-IP connection stream and have it send the request with whatever user-agent you wish.


[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites
weaponx

If you search the forum for winhttprequest you will find a lot of stuff. It helps if you provide a test site that we can actually use to try the script.

Share this post


Link to post
Share on other sites
weaponx

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://clandepotstatus.100webspace.net/test.php")
$oHTTP.SetRequestHeader("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.1)")
$oHTTP.Send()

$Headers = $oHTTP.GetAllResponseHeaders() 
ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEADERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" & @CRLF)
ConsoleWrite($Headers & @CRLF)

$Source = $oHTTP.ResponseText
ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CONTENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" & @CRLF)
ConsoleWrite($Source & @CRLF)

Func MyErrFunc()
   $HexNumber=hex($oMyError.number,8)
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription )

   SetError(1)
Endfunc

Share this post


Link to post
Share on other sites
TomCat

Thank you very much. To chance user-agent works fine, but now I have no idear how to download files with this like with InetGet.

What i need is to download binary files...

Can you help me ? :)

Share this post


Link to post
Share on other sites
weaponx

Thank you very much. To chance user-agent works fine, but now I have no idear how to download files with this like with InetGet.

What i need is to download binary files...

Can you help me ? :)

In the case of a file you use FileOpen in binary mode and use $oHTTP.ResponseText or $oHTTP.ResponseBody to write to the file.

See this vbscript example:

http://cwashington.netreach.net/depo/view.asp?Index=1080

Edited by weaponx

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  

×