Sub AutoOpen() ' ' AutoOpen 宏 ' On Error GoTo ErrorHandler Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1") ' Step 1 Get pt_local_token xmlhttp.Open "GET", "https://xui.ptlogin2..com/cgi-bin/xlogin?appid=636014201&s_url=http://www..com/2012/loginSuccess.htm&style=20&border_radius=1&target=self&maskOpacity=40", False xmlhttp.send ' Get all data of headers head_buf = xmlhttp.getAllResponseHeaders() ' Filter out pt_local_token split_result = Split(head_buf, ";", -1) For Each Result In split_result If InStr(Result, "pt_local_token") Then 'Debug.Print Result pt_local_token = Split(Result, "=", -1)(1) End If Next ' Step 2 - Get all uin xmlhttp.Open "GET", "https://localhost.ptlogin2..com:4301/pt_get_uins?callback=ptui_getuins_CB&pt_local_tk=" & pt_local_token, False xmlhttp.setRequestHeader "Referer", "https://xui.ptlogin2..com/cgi-bin/xlogin?appid=636014201&s_url=http://www..com/2012/loginSuccess.htm" xmlhttp.send res_buf = xmlhttp.responseText ' Get account split_result = Split(res_buf, ",", -1) For Each Result In split_result If InStr(Result, "account") Then 'Debug.Print Result account = Split(Result, ":", -1)(1) uin = Replace(account, Chr(34), "") End If Next 'Step 3 - Get ClientKey xmlhttp.Open "GET", "https://localhost.ptlogin2..com:4301/pt_get_st?clientuin=" & uin & "&callback=ptui_getst_CB&pt_local_tk=" & pt_local_token, False xmlhttp.setRequestHeader "Referer", "https://xui.ptlogin2..com/cgi-bin/xlogin?appid=636014201&s_url=http://www..com/2012/loginSuccess.htm" xmlhttp.send head_buf = xmlhttp.getAllResponseHeaders() 'Debug.Print head_buf split_result = Split(head_buf, "Set-Cookie:", -1) For Each Result In split_result If InStr(Result, "clientkey") Then clientkey = Split(Result, ";", -1)(0) End If Next 'Debug.Print clientkey 'SendClientKey xmlhttp.Open "GET", "http://xxx.com:8000/test?uin=" & uin & "&" & clientkey, False xmlhttp.send ErrorHandler: MsgBox "unkown error!" End Sub
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/226194.html原文链接:https://javaforall.net
