|
Dim Http As Object
Sub 搜房网登录()
Const UserName As String = "vbatest" '假设的账户
Const UserPwd As String = "12341234"
Dim strText As String, 前言 As String, 函数 As String, pwdRtn As String
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
With Http
'1、获取3个js文件的代码:RSA.js、BigInt.js、Barrett.js
前言 = httpRequest(Http, "http://img1.soufun.com/secondhouse/image/magent/js/RSA.js")
前言 = 前言 & httpRequest(Http, "http://img1.soufun.com/secondhouse/image/magent/js/BigInt.js")
前言 = 前言 & httpRequest(Http, "http://img1.soufun.com/secondhouse/image/magent/js/Barrett.js")
'2、截取函数cmdEncrypt的执行语句
strText = httpRequest(Http, "http://agent.fang.com/")
函数 = Mid(strText, InStr(strText, "setMaxDigits"))
函数 = Left(函数, InStr(函数, "var pwdRtn = ") - 1)
函数 = 函数 & "encryptedString(key, '" & UserPwd & "')" '不替换了,直接抄来var pwdRtn = 之后的算式
'3、将前言和函数结合后执行,取出pwdRtn值:
Set oDom = CreateObject("HtmlFile"): Set oWin = oDom.parentWindow: oWin.execScript
pwdRtn = oWin.eval(前言 & 函数)
'4、登录
.Open "POST", "http://agent.soufun.com/DealCenterLogin.aspx?codev=" & Round(Rnd * 10000), False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.Send "str_username=" & UserName & "&str_userpwd=" & pwdRtn & "&Submit1=%B5%C7++%C2%BC"
Debug.Print .getallresponseheaders '有三个Set-Cookie表明登录成功
End With
End Sub
Function httpRequest(Http, Url)
With Http
.Open "Get", Url, False
.Send
httpRequest = .ResponseText
End With
End Function |
|