找回密码
 加入
搜索
查看: 2871|回复: 3

[已成交] 30RBM求一个能获取内嵌ie完整cookies的代码

[复制链接]
发表于 2019-6-18 19:12:14 | 显示全部楼层 |阅读模式
悬赏1金钱已解决
本帖最后由 guoguo188 于 2019-6-18 23:09 编辑

一句话描述:用ie登录阿里妈妈网站后通过ie对象获取完整cookies来被winhttp使用困难:网站无法post登录,必须模拟,cookies包含httponly(cookie2 )

达成目标:提取出 cookie2 中的数据 看图



补充:可参考完善这个帖子的代码即可  http://www.autoitx.com/thread-53455-1-1.html
      (这个帖子 我提取出的cookie2 数据无法转换使用,也不知道代码正不正确。)


完整案例,送给有缘人,感谢发哥的帮忙
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseX64=n
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

#include <IE.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ARRAY.AU3>
#include <WinAPI.au3>
_AddMyIEVersion(1)
$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

                        MsgBox(0, 0, getjson())
        EndSwitch
;~         $cookies = _IEDocGetObj($ieobj).cookie
;~         If GUICtrlRead($Edit1) <> $cookies Then GUICtrlSetData($Edit1, $cookies)
WEnd
Func getjson($sUrl = 'http://www.taobao.com')        
        Local $iSize = 2048
        Local $tBuffer = DllStructCreate('wchar[' & $iSize & ']')
        Local $Ret = DllCall("wininet.dll", "bool", "InternetGetCookieExW", _
                        'wstr', $sUrl, _
                        'wstr', Null, _
                        "struct*", $tBuffer, _
                        "dword*", $iSize, _
                        "dword", 8192, _
                        "ptr", Null)        
        If @error Or Not $Ret[0] Then Return SetError(1, 0, 0)
        Return DllStructGetData($tBuffer, 1)
EndFunc   ;==>getjson
;接上面

Func _AddMyIEVersion($tag = 1)
        Local $script = @ScriptName
        If Not @Compiled Then
                If $tag = 1 Then
                        RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe', 'REG_DWORD', '9000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe', 'REG_DWORD', '9000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe', 'REG_DWORD', '9000')

                        RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe', 'REG_DWORD', '9000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe', 'REG_DWORD', '9000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe', 'REG_DWORD', '9000')
                Else
                        RegDelete('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe')
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe')
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3.exe')

                        RegDelete('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe')
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe')
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', 'AutoIt3_x64.exe')
                EndIf
        Else
                If $tag = 1 Then
                        RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script, 'REG_DWORD', '11000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script, 'REG_DWORD', '11000')
                        RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script, 'REG_DWORD', '11000')
                Else
                        RegDelete('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script)
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script)
                        RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', $script)
                EndIf
        EndIf
EndFunc   ;==>_AddMyIEVersion





发表于 2019-6-18 19:12:15 | 显示全部楼层
Func _WinINet_InternetGetCookieEx($sUrl = 'http://www.taobao.com')        
        Local $iSize = 2048
        Local $tBuffer = DllStructCreate('wchar[' & $iSize & ']')
        Local $Ret = DllCall("wininet.dll", "bool", "InternetGetCookieExW", _
                        'wstr', $sUrl, _
                        'wstr', Null, _
                        "struct*", $tBuffer, _
                        "dword*", $iSize, _
                        "dword", 8192, _
                        "ptr", Null)        
        If @error Or Not $Ret[0] Then Return SetError(1, 0, 0)
        Return DllStructGetData($tBuffer, 1)
EndFunc   ;==>getjson
 楼主| 发表于 2019-6-18 19:21:15 来自手机 | 显示全部楼层
不是要post获取,只要通过调用dll函数  InternetgetcookieExW 调用出来即可  
发表于 2019-6-22 22:00:17 | 显示全部楼层
好贴,收藏!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 18:35 , Processed in 0.073386 second(s), 18 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表