rietjevaldo Posted May 27, 2017 Share Posted May 27, 2017 How can i download a file? and get the name of the downloaded file? Link to comment Share on other sites More sharing options...
MattHiggs Posted May 27, 2017 Share Posted May 27, 2017 (edited) Pretty simple. You have to know what the url for the file on the web server is. You can do this by right-clicking the link which would start the download and selecting "Copy link address" or copy link location. Here is a script that I wrote which will scan a web page for all of the links that download a "zip" archive or executable file and download them preserving the file name. Then execution should be a cinche: ; Script Start - Add your code below here #include <IE.au3> DirCreate ( @UserProfileDir & "\Downloads\test" ) $oIE = _IECreate ( "http://www.mitec.cz/Data/XML/data_downloads.xml", Default, 0 ) _IELoadWait ( $oIE ) $links = _IELinkGetCollection ( $oIE ) For $link In $links If StringRight ( $link.href, 3 ) = "exe" Or StringRight ( $link.href, 3 ) = "zip" Then $split = StringSplit ( $link.href, "/" ) $file = InetGet ( $link.href, @UserProfileDir & "\Downloads\test\" & $split[$split[0]] ) InetClose ( $file ) Else ContinueLoop EndIf Next _IEQuit ( $oIE ) Shellexecutewait ( "file.exe", "", @UserProfileDir & "\Downloads\test" ) Edited May 27, 2017 by MattHiggs Link to comment Share on other sites More sharing options...
rietjevaldo Posted May 29, 2017 Author Share Posted May 29, 2017 On 2017-5-27 at 10:58 PM, MattHiggs said: Pretty simple. You have to know what the url for the file on the web server is. You can do this by right-clicking the link which would start the download and selecting "Copy link address" or copy link location. Here is a script that I wrote which will scan a web page for all of the links that download a "zip" archive or executable file and download them preserving the file name. Then execution should be a cinche: ; Script Start - Add your code below here #include <IE.au3> DirCreate ( @UserProfileDir & "\Downloads\test" ) $oIE = _IECreate ( "http://www.mitec.cz/Data/XML/data_downloads.xml", Default, 0 ) _IELoadWait ( $oIE ) $links = _IELinkGetCollection ( $oIE ) For $link In $links If StringRight ( $link.href, 3 ) = "exe" Or StringRight ( $link.href, 3 ) = "zip" Then $split = StringSplit ( $link.href, "/" ) $file = InetGet ( $link.href, @UserProfileDir & "\Downloads\test\" & $split[$split[0]] ) InetClose ( $file ) Else ContinueLoop EndIf Next _IEQuit ( $oIE ) Shellexecutewait ( "file.exe", "", @UserProfileDir & "\Downloads\test" ) gives me errors, links has to be an object or some shit Link to comment Share on other sites More sharing options...
anthonyjr2 Posted May 30, 2017 Share Posted May 30, 2017 It works perfectly fine for me, are you sure you copied it correctly? Keep in mind the ShellExecuteWait will not work as-is because there is no file in the download called "file.exe" but you should just be able to change the website and change the execute name and it will work. UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
Developers Jos Posted May 30, 2017 Developers Share Posted May 30, 2017 23 hours ago, rietjevaldo said: gives me errors, links has to be an object or some shit Ok let me get down to your level for a change to see if that helps: What the fuck do you imbecile expect from a stupid moron answer like that. You provided shit information so get your head out o your ass, kick it in gear and start thinking for a change! So got that out of my system. Let me know when you need to have that translated to Dutch, specifically the dialect used "below the rivers". Jos Danyfirex 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts