回复 14# nangua111111
Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHTTP.Option(0) = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)"
$oHTTP.SetTimeouts(30000, 30000, 30000, 30000)
Local $sUrl, $sBody, $sData, $aMatch, $t
Local $sUser = "ggg111"
Local $sPass = "ggg111"
$sUrl = "http://www.51aspx.com/Sso/Login?mode=dlg&returnUrl=http://www.51aspx.com/&t=" & Random()
$oHTTP.Open("GET", $sUrl, True)
$oHTTP.Send()
$sBody = waitResponse()
$aMatch = StringRegExp($sBody, "&t=(\d+)", 3)
If Not @error Then
$sUrl = "http://www.51aspx.com/Home/Token?source=login&t=" & $aMatch[0]
ConsoleWrite($sUrl & @CRLF)
$oHTTP.Open("GET", $sUrl, True)
$oHTTP.Send()
$sBody = waitResponse()
$sData = "login_name=" & $sUser & "&login_pwd=" & $sPass & "&login_token="
$oHTTP.Open("POST", "http://www.51aspx.com/Sso/Login", True)
$oHTTP.setRequestHeader("Referer", "http://www.51aspx.com/")
$oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($sData)
$sBody = waitResponse()
ConsoleWrite($sBody & @CRLF)
If StringInStr($sBody, 'success":true') Then MsgBox(64, "", "登陆成功")
EndIf
Func waitResponse($i_Time = -1, $b_Bin = False)
Local $s_Header = ""
If Not $oHTTP.WaitForResponse($i_Time) Then
$oHTTP.Abort()
Return SetError(1, 0, "")
EndIf
If $b_Bin Then Return $oHTTP.responseBody
$s_Header = $oHTTP.GetResponseHeader("Content-Type")
If StringInStr($s_Header, "gb2312") Or StringInStr($s_Header, "gbk") Then
Return BinaryToString($oHTTP.responseBody, 1)
Else
Return BinaryToString($oHTTP.responseBody, 4)
EndIf
EndFunc
|