Graeme Posted January 14, 2014 Share Posted January 14, 2014 Hi, I'm trying to automate downloading update files of a few programs and all work except TrueCrypt because I can't find the file to download with InetGet. The web page has a button to click and no file that gets downloaded as far as I can see. I tried using WinHttpSimpleFormFill as below and it "works" but only downloads 454K whereas the file should be 3.386M! Can anyone tell me what I'm doing wrong, please? #include <IE.au3> #include <inet.au3> #include <winhttp.au3> Global $hConnect, $hOpen, $H, $sRead $hOpen = _WinHttpOpen() $hConnect= _WinHttpConnect($hOpen, "http://www.truecrypt.org") $sRead = _WinHttpSimpleFormFill($hConnect,"downloads", "name:WindowsDownLoads","name:WindowsDownLoads") _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If $sRead Then $H=FileOpen("TrueCryptTmp",2) FileWrite($H,$sRead) FileClose($H) MsgBox(0,"running","Saved something") EndIf Link to comment Share on other sites More sharing options...
Danp2 Posted January 14, 2014 Share Posted January 14, 2014 Try changing line 12 to read $sRead = _WinHttpSimpleFormFill($hConnect,"downloads", "name:WindowsDownLoads","name:WindowsDownLoad","Download") You may also have to account for the two hidden fields on the form. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks DanP2, Tried that, correcting the misspelling - but to no avail. Still get the 454KB Not sure how to take account of the hidden fields... Is it possible that the whole 3MB wouldn't fit and got put in an array or something? I really am a newbie at this:) When I opened the TrueCryptTmp file with Notepad it looked like the beginnings of a program.... Blessings Link to comment Share on other sites More sharing options...
Danp2 Posted January 14, 2014 Share Posted January 14, 2014 I don't believe that _WinHttpSimpleFormFill is designed to return binary data. You could always switch to Inetget and use the url "http://www.truecrypt.org/download/transient/6a69f667df956015f801/TrueCrypt%20Setup%207.1a.exe". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks for that DanP2! Tried it and got 0bytes... What did I do wrong? This is the kind of thing I did with Eraser, CCleaner and OpenVPN and it worked with them.. BTW, how did you find the url? That's what I looked for and could never find.. This is what I tried that didn't work... $sRead="http://www.truecrypt.org/download/transient/6a69f667df956015f801/TrueCrypt%20Setup%207.1a.exe" $H=Inetget($sRead,@ScriptDir&"\TempTruecrypt.exe",1) $I = InetGetSize($sRead) MsgBox(0,"Running",$I& " is the size") InetClose($H) Link to comment Share on other sites More sharing options...
Danp2 Posted January 14, 2014 Share Posted January 14, 2014 The link must be dynamic. FWIW, I got the url by downloading the file in Firefox and then copying the download link from the download library. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Now there's an interesting thing! I downloaded the file and copied the link and it was different. Downloaded it three times and each time got the same link! Put that link back in the program and it worked! But ... will this work anywhere else??? Why and when does it change? Is it by country? I'm in England - could anyone try downloading the file and send me the link with an idea where you are?? Or is this off topic?? Facinating none the less. Blessings Graeme Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Oh no! Not as simple as that. Downloaded it again and got a different link. I think I'll need to find a way of automating the clicking of the button. No way round that. Hope someone has an idea .. Looking forward to reading from you. Blessings Graeme Link to comment Share on other sites More sharing options...
jdelaney Posted January 14, 2014 Share Posted January 14, 2014 Post the HTML source of the Span (button)...and all it's child elements, if present. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks for your response jdelaney. Is this the sort of html that you mean? <form action="/dl" method="post" enctype="multipart/form-data" name="WindowsDownloads"> <input type="hidden" value="7.1a" name="DownloadVersion"></input> <input type="hidden" value="644099df924498e3e95a" name="LinkT"></input> <input type="submit" value="Download" name="WindowsDownload"></input> </form> Link to comment Share on other sites More sharing options...
jdelaney Posted January 14, 2014 Share Posted January 14, 2014 (edited) Are those "hidden" input.value attributes combined in anyway in the link? That might be how to help construct the URL. Edited January 14, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 Yes, I think we're on to it, here is the copy of the source <form name="WindowsDownloads" enctype="multipart/form-data" method="post" action="/dl"><input type="hidden" name="DownloadVersion" value="7.1a"><input type="hidden" name="LinkT" value="4c76caca415df8912330"><input type="submit" name="WindowsDownload" value="Download"></form></td> and this is the download link http://www.truecrypt.org/download/transient/4c76caca415df8912330/TrueCrypt%20Setup%207.1a.exe! But wait, I used this to try and read this data $sRead= _StringBetween(_INetGetSource("http://www.truecrypt.org/download"),"LinkT","WindowsDownLoad") and got @error =1... Really appreciate any ideas.. Link to comment Share on other sites More sharing options...
Graeme Posted January 14, 2014 Author Share Posted January 14, 2014 The eagle eyed will have noticed that there is a world of difference between _INetGetSource("http://www.truecrypt.org/download") AND _INetGetSource("http://www.truecrypt.org/downloads") I think(?) I have it working now!! Thank you SO much for all your help... Link to comment Share on other sites More sharing options...
Solution jdelaney Posted January 14, 2014 Solution Share Posted January 14, 2014 Using IE.au3 #include <ie.au3> $string= '<form action="/dl" method="post" enctype="multipart/form-data" name="WindowsDownloads">' & @CRLF & _ '<input type="hidden" value="7.1a" name="DownloadVersion"></input>' & @CRLF & _ '<input type="hidden" value="644099df924498e3e95a" name="LinkT"></input>' & @CRLF & _ '<input type="submit" value="Download" name="WindowsDownload"></input>' & @CRLF & _ ' </form>' $oIE = _IECreate("about:blank",0,0) _IEBodyWriteHTML($oIE,$string) $oDownloadVersion = _IEGetObjByName($oIE,"DownloadVersion") $oLinkT = _IEGetObjByName($oIE,"LinkT") $oWindowsDownload = _IEGetObjByName($oIE,"WindowsDownload") ConsoleWrite($oDownloadVersion.value & @CRLF) ConsoleWrite($oLinkT.value & @CRLF) ConsoleWrite($oWindowsDownload.value & @CRLF) _IEQuit($oIE) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
hiho Posted January 14, 2014 Share Posted January 14, 2014 #include <Inet.au3> #include <String.au3> ;~ #include <Array.au3> $sSource = _INetGetSource('http://www.truecrypt.org/downloads') ;~ ConsoleWrite($sSource) $aTemp = _StringBetween($sSource, '<input type="hidden" name="LinkT" value="', '"><input type="submit" name="WindowsDownload" value="Download"></form></td>') ;~ _ArrayDisplay($aTemp) $hDownload = InetGet("http://www.truecrypt.org/download/transient/" & $aTemp[0] & "/TrueCrypt Setup 7.1a.exe", @DesktopDir & "\TrueCrypt Setup 7.1a.exe", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) $nBytes = InetGetInfo($hDownload, 0) If Not @error And $nBytes > 0 Then MsgBox(0, "", "Bytes read: " & $nBytes) Else MsgBox(0, "", @error) EndIf InetClose($hDownload) Link to comment Share on other sites More sharing options...
trancexx Posted January 14, 2014 Share Posted January 14, 2014 (edited) Hi, I'm trying to automate downloading update files of a few programs and all work except TrueCrypt because I can't find the file to download with InetGet. The web page has a button to click and no file that gets downloaded as far as I can see. I tried using WinHttpSimpleFormFill as below and it "works" but only downloads 454K whereas the file should be 3.386M! Can anyone tell me what I'm doing wrong, please? It's what Danp2 said about binary data and _WinHttpSimpleFormFill function. But it's my fault because it doesn't need to be like that. Your code sholud have been working out of the box. I will fix it... right now. edit: there, if you are still interested it's right here. Edited January 14, 2014 by trancexx ♡♡♡ . eMyvnE 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