For i=0 To UBound(user)
Set http = CreateObject("Msxml2.ServerXMLHTTP")
If login(user(i),pass(i)) Then '登录
code = getCode() '获取摇奖码
If Len(code) Then
Set o=getSpace(code) '摇奖,返回json对象
If o.state Then '判断摇奖状态
'返回数据样例:{"state":true,"picked":"88MB","picked_num":88,"flag":false,"total_size":"71829MB","used_percent":"28%","exp":985}
WScript.Echo vbCrLf, user(i), "本次摇奖信息:", vbCrLf, "获得空间:", o.picked, ", 获得雨露:", o.Exp, ", 总空间:", o.total_size, ", 已经使用:", o.used_percent
Else
WScript.Echo vbCrLf, user(i), "摇奖失败 或者 已经摇过了"
End If
Else
WScript.Echo vbCrLf, user(i), "今天已经摇过了..."
End If
Else
WScript.Echo vbCrLf, user(i), "登录失败!..."
End If
Set http = Nothing
Next
If autoExit Then WScript.Quit '是否自动退出
WScript.Echo vbCrLf, "按任意键退出..."
WScript.StdIn.ReadLine
Function HttpPost(url, data) 'POST函数
With http
.open "POST", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send data
HttpPost = .responseText
End With
End Function
Function HttpGet(url) 'GET函数
With http
.open "GET", url, False
.send
HttpGet = .responseText
End With
End Function
Function login(user, password) '登录函数
url = "http://passport.115.com/?ac=login"
data= "login%5Baccount%5D=" & user & "&login%5Bpasswd%5D=" & password
login=Len(HttpPost(url,data))<999
End Function
Function getCode() '读取摇奖码
Set reg = New RegExp
reg.IgnoreCase = True
reg.Global = True
reg.MultiLine = True
reg.Pattern = "take_token: '([^']+)',"
html = HttpGet("http://115.com/")
If reg.Test(html) Then getCode=Trim(reg.Execute(html).Item(0).Submatches(0)) Else getCode=""
End Function
Function getSpace(code) '摇奖
url = "http://115.com/?ct=ajax_user&ac=pick_spaces&u=1&token=" & code & "&_=" & Rnd
Set getSpace = ParseJson(HttpGet(url))
End Function
Function ParseJson(strJson) 'JSON数据解析
Set htmlfile = CreateObject("htmlfile")
Set owindow = htmlfile.parentWindow
owindow.execScript "var json_obj = " & strJson, "JScript"
Set ParseJson = owindow.json_obj
End Function
Function CmdMode(title, color) '命令行模式运行
If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
With CreateObject("Wscript.Shell")
.Run "cmd /c title " & title & "&color " & color & "&Cscript //Nologo """ & WScript.ScriptFullName & """"
.Run "taskkill /f /im cmd.exe",0
End With
WScript.Quit
End If
End Function