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":"92MB","picked_num":92,"flag":false,"total_size":"15620MB","used_percent":"0%","exp":966}
WScript.Echo vbCrLf, user(i), "本次摇奖信息:", vbCrLf, "获得空间:", o.picked, ", 获得雨露:", o.Exp, ", 总空间:", o.total_size, ", 已经使用:", o.used_percent
Else
WScript.Echo user(i), "摇奖失败 或者 已经摇过了"
End If
Else
WScript.Echo user(i), "今天已经摇过了..."
End If
Else
WScript.Echo user(i), "登录失败!..."
End If
Set http = Nothing
Next
If autoExit Then WScript.Quit '是否自动退出
WScript.Echo vbCrLf, "按任意键退出..."
WScript.StdIn.ReadLine
Function HttpPost(ByVal url, ByVal 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(ByVal 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="back=http%3A%2F%2Fwww.115.com&goto=http%3A%2F%2F115.com&login%5Baccount%5D=" & user & "&login%5Bpasswd%5D=" & password
login = Len(HttpPost(url,data))<99
End Function
Function getCode() '读取摇奖码
Set reg = New RegExp
reg.IgnoreCase = True
reg.Global = True
reg.MultiLine = True
reg.Pattern = "Yao\('(.*)',\s*function"
html = HttpGet("http://115.com/?ct=index&ac=home")
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_space&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(ByVal title,ByVal 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 作者: zhangop9 时间: 2013-10-21 19:54