|
#include <IE.au3>
#include "WinHttp.au3"
Opt("MustDeclareVars", 1)
;方法1
$Url = "http://www.autoitx.com"
$oIE = _IECreate ($URL,0)
$Obj = _IEDocGetObj($oIE)
$Cookie = $Obj.cookie
;方法2
; Open needed handles
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, "www.autoitx.com")
; Specify the reguest:
Global $hRequest = _WinHttpOpenRequest($hConnect, Default, "/")
; Send request
_WinHttpSendRequest($hRequest)
; Wait for the response
_WinHttpReceiveResponse($hRequest)
;MsgBox(0,'',_WinHttpQueryOption($hOpen,$WINHTTP_QUERY_COOKIE))
Global $sHeader
; If there is data available...
If _WinHttpQueryDataAvailable($hRequest) Then $sHeader = _WinHttpQueryHeaders($hRequest,43,Default,0) ; ...get full header
; Clean
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
; Display retrieved header
MsgBox(0, "Header", $sHeader & @CRLF & "------" & @CRLF & $Cookie)
为什么2种方法获取的cookies会不一样呢?急求解 |
|