InetRead
使用 HTTP,HTTPS 或 FTP 协议下载文件.
InetRead ( "URL" [, options = 0] )
参数
URL
|
要下载文件的 URL(地址) . 见备注.
|
options
|
[可选]
$INET_LOCALCACHE (0) = 如有可能,则从本地缓存中获取文件 (默认)
$INET_FORCERELOAD (1) = 强制从远程站点重新加载.
$INET_IGNORESSL (2) = 忽略所有 SSL 错误(使用 HTTPS 连接时).
$INET_ASCIITRANSFER (4) = 使用 FTP 协议传输 ASCII 文件(不能和标志 $INET_BINARYTRANSFER (8) 一起使用).
$INET_BINARYTRANSFER (8) = 使用 FTP 协议传输二进制文件(不能和标志 $INET_ASCIITRANSFER (4) 一起使用). 这是默认传输方式.
$INET_FORCEBYPASS (16) = 强制在线连接(见备注).
常量定义在 InetConstants.au3
|
返回值
成功:
|
返回二进制字符串, @extended 为下载的字节数.
|
失败:
|
返回空字符串, @error 设置 为非 0 值.
|
备注
必须 Internet Explorer 3 或更高版本.
URL 参数的形式 "http://www.somesite.com/path/file.html" - 如同在网页浏览器中输入的地址.
指定用户名及密码,只要在服务器前加 "用户名:密码@", 例如:
"http://myuser:mypassword@www.somesite.com"
返回的数据为二进制格式. 可使用 BinaryToString() 函数将数据转换为字符串.
默认 AutoIt 开始下载前强制连接. 对于拨号上网用户将提示联机或调制解调器拨号(取决于系统配置而定). 选项值 $INET_FORCEBYPASS (16) 将禁用此行为.
对于宽带, 局域网的持久性连接, 禁用的行为会很有用.
但也需要解决 Windows Vista 与 Windows 7 的某些问题.
函数示例
#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
----------------------------------------
该函数可以通过命令调用 exect
参见:
InetGet, InetGetSize, HttpSetProxy, FtpSetProxy, HttpSetUserAgent
exect=$var_b=InetRead('http://tc-image.3dn.ru')||_ViewValues('$var_b') ;; 从页面tc-image.3dn.ru获取二进制数据
exect=$var_b=InetRead('http://tc-image.3dn.ru')||_ViewValues(BinaryToString('$var_b',4)) ;; 从页面tc-image.3dn.ru获取文本数据
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|