Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
InetRead ( "URL" [, options = 0] )
|URL||URL of the file to download. See remarks below.|
$INET_LOCALCACHE (0) = Get the file from local cache if available (default).
$INET_FORCERELOAD (1) = Forces a reload from the remote site.
$INET_IGNORESSL (2) = Ignore all SSL errors (with HTTPS connections).
$INET_ASCIITRANSFER (4) = Use ASCII when transferring files with the FTP protocol (Can not be combined with flag $INET_BINARYTRANSFER (8)).
$INET_BINARYTRANSFER (8) = Use BINARY when transferring files with the FTP protocol (Can not be combined with flag $INET_ASCIITRANSFER (4)). This is the default transfer mode if none are provided.
$INET_FORCEBYPASS (16) = By-pass forcing the connection online (See remarks).
Constants are defined in InetConstants.au3.
|Success:||a binary string and @extended set to the number of bytes downloaded.|
|Failure:||"" (empty string) and sets the @error flag to non-zero.|
Internet Explorer 3 or greater must be installed for this function to work.
The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.
To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
The returned data is in binary format. The BinaryToString() function can be used to convert the data to a string.
By default AutoIt forces a connection before starting a download. For dial-up users this will prompt to go online or dial the modem (depending on how the system is configured). The options value $INET_FORCEBYPASS (16) disables this behavior. Disabling the behavior can be useful for persistent connects (Broadband, LAN). However, it is also required to work around certain issues in Windows Vista and Windows 7.
FtpSetProxy, HttpSetProxy, HttpSetUserAgent, InetGet, InetGetSize
#include <MsgBoxConstants.au3> Example() Func Example() ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected. Local $dData = InetRead("http://www.autoitscript.com/autoit3/files/beta/update.dat") ; The number of bytes read is returned using the @extended macro. Local $iBytesRead = @extended ; Convert the ANSI compatible binary string back into a string. Local $sData = BinaryToString($dData) ; Display the results. MsgBox($MB_SYSTEMMODAL, "", "The number of bytes read: " & $iBytesRead & @CRLF & @CRLF & $sData) EndFunc ;==>Example