Au3Builder Posted July 17, 2015 Share Posted July 17, 2015 (edited) Hi guys.I'am using this UDF https://github.com/dragana-r/autoit-winhttp/releases for http operations.I already make an auto-login script for a website which is required to download an exe file which is only available for premium users.Now I struggle download this file.the download location doesn't change so it should be simple.Do I need to delivier any extra information or can I please any example on how to do it? Edited July 17, 2015 by Au3Builder Link to comment Share on other sites More sharing options...
trancexx Posted July 17, 2015 Share Posted July 17, 2015 Without more info it's really hard to give any good advice.If you've managed to login then downloading a file should be fairly simple task. I've noticed that usually the problem users have is that they don't know they should reuse either connection or session handle for the new task. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Au3Builder Posted July 17, 2015 Author Share Posted July 17, 2015 (edited) Thanks for your reply.I have written a new script,less complicated,should be good as an example.I believe the file is downloading somehwere as it waits before shows second message. I have no idea how to choose the download location.Take a look please and if thats not a problem fix it.all i want is download the file.thanks #include <WinHTTP.au3> download() func download() Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 OPR/30.0.1835.125") $hConnect = _WinHttpConnect($hOpen,"http://www.aida64.com/") $request = _WinHttpSimplerequest($hConnect,"GET","/downloads/latesta64xe","http://www.aida64.com/") _WinHttpAddRequestHeaders($hConnect,"Connection:Keep-Alive") _WinHttpAddRequestHeaders($hConnect,"Content-Language:en") _WinHttpAddRequestHeaders($hConnect,"Content-Encoding:gzip") _WinHttpAddRequestHeaders($hConnect,"Content-Type:text/html; charset=utf-8") _WinHttpAddRequestHeaders($hConnect,"Content-Length:5800") MsgBox(0,'',$request) _WinHttpAddRequestHeaders($hConnect,"Connection:Keep-Alive") _WinHttpAddRequestHeaders($hConnect,"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") $hConnect2 = _WinHttpConnect($hOpen,"http://download.aida64.com/") $request2 = _WinHttpSimplerequest($hConnect2,"GET","/aida64extreme520.exe","http://download.aida64.com/") MsgBox(0,'',$request2) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) EndFunc Edited July 17, 2015 by Au3Builder Link to comment Share on other sites More sharing options...
Au3Builder Posted July 17, 2015 Author Share Posted July 17, 2015 This is what a network sniffer says.GET /downloads/latesta64xe HTTP/1.1Connection: Keep-AliveReferer: http://www.aida64.com/User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 OPR/30.0.1835.125Host: www.aida64.com GET /aida64extreme520.exe HTTP/1.1Connection: Keep-AliveReferer: http://download.aida64.com/User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 OPR/30.0.1835.125Host: download.aida64.com Link to comment Share on other sites More sharing options...
trancexx Posted July 17, 2015 Share Posted July 17, 2015 #include "WinHttp.au3" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, "http://download.aida64.com") ; Request $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "aida64extreme520.exe") ; Download to file (it's in the same folder as your script) $hFile = FileOpen(@ScriptDir & "\aida64extreme520.exe", 26) FileWrite($hFile, _WinHttpSimpleReadData($hRequest)) FileClose($hFile) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)But why in the world would you use WinHttp.au3 for this? Use built-in InetGet(). Au3Builder 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Au3Builder Posted July 17, 2015 Author Share Posted July 17, 2015 (edited) Thanks very much.I am testing my script right now.Why? Like I said before,I must be authorized on the website to download files from there. I only needed to know how to download an exe file.Ok then I will let u know if I still have a problem. Edited July 17, 2015 by Au3Builder Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now