|
发表于 2012-12-27 15:39:40
|
显示全部楼层
本帖最后由 netegg 于 2012-12-27 15:42 编辑
[au3]#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinHttp.au3>
Opt('MustDeclareVars', 1)
Global $iMemo,$hOpen,$hConnect,$hRequest,$sChunk
_mani()
Func _mani()
GUICreate("HTTP Data", 800, 600)
$iMemo = GUICtrlCreateEdit("", 2, 2, 796, 596, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; 初始化并获取会话句柄
$hOpen = _WinHttpOpen()
$hConnect = _WinHttpConnect($hOpen, "sciencedirect.com")
$hRequest = _WinHttpOpenRequest($hConnect, "POST", "/science/article/pii/B9780122841514500002")
_WinHttpSendRequest($hRequest)
_WinHttpReceiveResponse($hRequest)
If _WinHttpQueryDataAvailable($hRequest) Then
While 1
$sChunk = _WinHttpReadData($hRequest) ; 读取数据
If @error Then ExitLoop
MemoWrite($sChunk)
Wend
else
MsgBox(48, "Error occurred", "Site is experiencing problems.")
EndIf
; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>__WINHTTP_STATUS_CALLBACK
; 向memo控件写入信息
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite[/au3] |
|