Jump to content

Downloading a file with InetGet


x2norm
 Share

Recommended Posts

 

This code does not work. It does not download the file. As i understand it, the file should be downloaded to the Public Download dir. it does not. I have confimred that the Url is correct. 

 

#include <InetConstants.au3>
 

Local $sFilePath = "C:\Users\Public\Downloads\alteadccm.zip" 

InetGet("https://support.airline-choice.com\downloads\Altea\AlteaDCCM.zip", $sFilePath)

 

Any ideas how to capture an error or something that would give me a clue as to why the file does not download? 

 

thanks, 

Link to comment
Share on other sites

@error will tell.  I was not able to DL it at first.  I manually rewrote the URL and then it started working.  Maybe a bad char inside the string, idk.

Try this :

#include <FileConstants.au3>
#include <Constants.au3>
#include <InetConstants.au3>
#include <IE.au3>

Local $sFilePath = "alteadccm.zip"
Local $sUrl = "https://support.airline-choice.com/downloads/Altea/AlteaDCCM.zip"

Local $iReturn = InetGet($sUrl, $sFilePath, $INET_FORCERELOAD+$INET_BINARYTRANSFER)
MsgBox ($MB_SYSTEMMODAL,"",$iReturn & "/" & @error)

; also work with IE
;$oIE = _IECreate ($sUrl)

ps. just noticed that your were using backslash in url...

Edited by Nine
Link to comment
Share on other sites

#include <InetConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPIShellEx.au3>

Global $g_sURL           = "https://support.airline-choice.com/downloads/Altea/"
Global $g_sDownloadPath  = _WinAPI_ShellGetKnownFolderPath($FOLDERID_Downloads)
Global $g_sFilename      = "AlteaDCCM.zip"

ConsoleWrite("> Path for Downloads = " & $g_sDownloadPath & "\" & $g_sFilename & @CRLF)

_Download()

Func _Download()
    Local $hDownload = InetGet($g_sURL & $g_sFilename, $g_sDownloadPath & "\" & $g_sFilename, BitOR($INET_FORCERELOAD, $INET_BINARYTRANSFER), $INET_DOWNLOADBACKGROUND)
    ; Wait for the download to complete :
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; total bytes received and filesize :
    ConsoleWrite("BytesSize InetGetInfo = " & InetGetInfo($hDownload, $INET_DOWNLOADREAD) & @CRLF)
    ConsoleWrite("BytesSize Local File  = " & FileGetSize($g_sDownloadPath & "\" & $g_sFilename) & @CRLF)
    InetClose($hDownload)
EndFunc   ;==>_Download

EDIT : Depending on your internet speed ==> The file is quite big, so please wait !

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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...