Making your AutoIt HTTP Requests go trough a proxy is very easy, all you really have to do, is add a single line of code to the examples provided in the last AutoIt Tutorials. The difficult part can be to make it work with the popular "SOCKS" proxy servers, how to do that will not be covered in this Tutorial, but you can use programs such as Privoxy to make your AutoIt programs indirectly use SOCKS proxies.
Using proxies with AutoIt can be useful in many situations, mostly to avoid IP bans or hide your own IP address however – this most likely means that you will be breaking some rules somewhere.
AutoIt With Proxies
To use a proxy server with winhttprequest in AutoIt, you need to use the SetProxy method of winhttprequest, this can be done by adding the method before the Send method has been used. The method looks like the below:
Replace the IP number with the proxy that you want to use, the part after the colon ":" is the port number of the proxy – this is often 80 or 8080. Adding the SetProxy method to one of the AutoIt examples from earlier would give us the following code:
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://brugbart.com/", False) $oHttp.SetProxy(2,"10.0.0.4:80") $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode == 200 then $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists FileWrite($file, $oReceived) FileClose($file) EndIf
What are proxy servers?
Proxy servers are used to hide your real IP address, making it difficult – sometimes impossible – to track you down.
When it comes to automation, proxy servers are often used to get around limits and blocks associated with different online services.
SOCKS Proxies and AutoIt
AutoIt does not natively support SOCKS proxy servers, you can however script it yourself – but that can be a tedious task. It's better to use a proxy, such as Privoxy, to route HTTP traffic trough the SOCKS server.