Jump to content

Help me InetGet not work


Recommended Posts

hi guy

I want to download a .exe file to temp that does not work when it is downloaded and it displays an error

my code:

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Math.au3>
; Download a file in the background.
; Wait for the download to complete.

Example()

Func Example()


$_FinalUrl = 'https://download1325.mediafire.com/osdeo2qshdyg/frdcbjk27591sda/Launcher.exe'
$_TempPath = @TempDir & '\laucher.exe'
$_FileSize = InetGetSize ( $_FinalUrl )
$_Gui = GUICreate ( "" )
$_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 )
GUISetState ( @SW_SHOW )
$_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 )
Local $_InfoData
Do
    $_InfoData = InetGetInfo ( $_Download )
    If Not @error Then
        $_InetGet = $_InfoData[0]
        $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
        $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
        GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
        $_Label = GUICtrlCreateLabel ( 'progress : ' & $_DownloadPercent & ' %', 5, 52, 350, 20 )
    EndIf
    Sleep ( 100 )
Until $_InfoData[2] = True
$_Label = GUICtrlCreateLabel ( 'Download successfull !', 5, 52, 350, 20 )
Sleep ( 2000 )

EndFunc   ;==>Example

 

Edited by HADE
Link to comment
Share on other sites

  • Developers

Looks like the download link is not a direct download of the file but you are redirected, on which case this won't work.

Jos

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

4 hours ago, Exit said:

What is your error? 

The error is that the downloaded exe is 28 KB instead of 74 MB  :idiot:

To follow a redirection you might use WinHttp or Curl
Example (works for me but the mediafire url may change)

#include <AutoItConstants.au3>

_Curl_Get("http://download2262.mediafire.com/5knc02qzoffg/frdcbjk27591sda/Launcher.exe", "Launcher.exe")
Msgbox(0,"", "done")


Func _Curl_Get($source, $dest)
   $cmd = "curl -L -s -k -A 'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1)' " & $source & " -o " & $dest
   RunWait($cmd, "", @SW_HIDE)
EndFunc

#cs
-L   --location  :  follow redirection(s)
-s   --silent   :  show only requested data
-k   --insecure  :  for SSL connections possibly insecure
-A  --user-agent
#ce

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...