本帖最后由 fenhanxue 于 2017-3-12 14:47 编辑 #include <IE.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ARRAY.AU3>
#include <WinAPI.au3>
$Form1 = GUICreate("Form1", 623, 600, 192, 114)
$ieobj = _IECreateEmbedded()
GUICtrlCreateObj($ieobj, 0, 0, 617, 393)
_IENavigate($ieobj, "https://passport.yhd.com/passport/login_input.do?")
$Ele = _IEGetObjById($ieobj,"un")
_IEFormElementSetValue($Ele,"13078480989")
$Ele = _IEGetObjById($ieobj,"pwd")
_IEFormElementSetValue($Ele,"9zuzz4yk9")
;账号:13078480989 密码:9zuzz4yk9
$Edit1 = GUICtrlCreateEdit("", 0, 400, 617, 140, $WS_VSCROLL)
$button = GUICtrlCreateButton("提交", 270, 560, 80, 30)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button
getjson()
EndSwitch
$cookies = _IEDocGetObj($ieobj).cookie
If GUICtrlRead($Edit1) <> $cookies Then GUICtrlSetData($Edit1, $cookies)
WEnd
Func getjson()
Global $INTERNET_COOKIE_HTTPONLY = 8192 ;Requires IE 8 or higher
Global $INTERNET_COOKIE_THIRD_PARTY = 131072
Global $INTERNET_FLAG_RESTRICTED_ZONE = 16
Global $sUrl = _IEPropertyGet($ieobj ,"locationurl")
Global $sCookieName = 'ut'
Global $tSize = DllStructCreate("dword[10000]")
Global $tBuffer = DllStructCreate('char[10000]')
Global $getcookies = DllCall("wininet.dll", _
"bool", "InternetGetCookieExW", _
'wstr', $sUrl, _
'wstr', $sCookieName, _
"ptr", DllStructGetPtr($tBuffer), _
"ptr", DllStructGetPtr($tSize), _
"dword", $INTERNET_COOKIE_HTTPONLY, _
"ptr", Null _
)
If Not _WinAPI_GetLastError() Then ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF)
ConsoleWrite(_WinAPI_GetLastError() & @CRLF)
_ArrayDisplay($getcookies)
EndFunc ;==>getjson
以一号店登陆为例,一号店登陆之后,用httpwatch , 能看到有下面这个叫做 ut 的cookie
但是用_IEDocGetObj($ieobj).cookie 却得到不这个 ut
不知是为什么,如何才能获取到?
|