从一个请求中读取数据
#Include <WinHttp.au3>
_WinHttpSimpleReadData($hRequest [, $iMode = Default ])
$hRequest | _WinHttpReceiveResponse 函数返回的请求句柄 |
$iMode | [可选参数] 返回数据的类型 (默认: 0) 0 - ASCII-字符串 1 - UTF-8-字符串 2 - 二进制数据 |
成功: | 根据 $iMode 指定类型返回字符串或二进制数据 |
失败: | 返回空字符串或空二进制(类型 2) 并设置@error |
1 - 无效类型 | |
2 - 无可用数据 |
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include "WinHttp.au3"
Opt("MustDeclareVars", 1)
; 初始化并获取会话句柄
Global $hOpen = _WinHttpOpen()
; 获取连接句柄
Global $hConnect = _WinHttpConnect($hOpen, "thetimes.co.uk")
; 请求
Global $hRequest = _WinHttpSimpleSendRequest($hConnect)
; 简单读取...
Global $sRead = _WinHttpSimpleReadData($hRequest)
MsgBox(64, "Returned (first 1100 characters)", StringLeft($sRead, 1100) & "...")
; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)