Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
InetGet ( "URL" [,"filename" [, options [, background]]] )
| URL | URL of the file to download. See remarks below. |
| filename | [optional] Local filename to download to. |
| options | [optional] 0 = (default) Get the file from local cache if available. 1 = Forces a reload from the remote site. 2 = Ignore all SSL errors (with HTTPS connections). 4 = Use ASCII when transfering files with the FTP protocol (Can not be combined with flag 8). 8 = Use BINARY when transfering files with the FTP protocol (Can not be combined with flag 4). This is the default transfer mode if none are provided. 16 = By-pass forcing the connection online (See remarks). |
| background | [optional] 0 = (default) Wait until the download is complete before continuing. 1 = return immediately and download in the background (see remarks). |
| Success: | The return value changes depending on if the download is in the background: |
| Background: A handle is returned. The handle can be used with InetGetInfo(). The handle must be closed with InetClose(). | |
| Wait: The number of bytes downloaded. | |
| Failure: | Background: A handle is returned. To determine if there was an error with the download, use InetGetInfo(). The handle must be closed with InetClose(). |
| Wait: Sets @error to non-zero and returns 0. |
InetGet("http://www.mozilla.org", @TempDir & "\mozilla.html")
InetGet("http://www.autoitscript.com", @TempDir & "autoitscript.html", 1)
InetGet("ftp://ftp.mozilla.org/pub/mozilla.org/README", @TempDir & "\Mozilla-README.txt", 1)
; Advanced example - downloading in the background
Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1)
Do
Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.
MsgBox(0, "", "Bytes read: " & $nBytes)