还是,淘宝的登录页面,有一个cookie2的cookie字段, 只要能获取到他就ok了
完整可重现代码:
#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://login.taobao.com/member/login.jhtml?style=mini&from=alimama")
$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 = 'cookie2'
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)
;~
;~ $url = "http://pub.alimama.com/pubauc/getCommonCampaignByItemId.json?itemId=528423266110"
;~ $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
;~ $oHTTP.Open("get", $url, False)
;~ $oHTTP.setRequestHeader("Cookie", ClipGet())
;~ $oHTTP.Send()
;~ $dxjson = $oHTTP.responsebody
;~ MsgBox(0, 0, BinaryToString($dxjson, 4))
EndFunc ;==>getjson
|