搞了很久,让人头大的问题!!
目的:ASP 登陆QQ空间,只需要获得登陆成功状态即可。
运行之后,一直提示输入有误,请重试,自己猜测还是验证码处有问题。
自己也就能写到这样了,麻烦高手帮忙改进,PHP可以比较完美的做到这个,看看ASP行不行。
头都大了,一直都不能成功登陆进去……高手在哪里
剩余这些分都给了,可能不够多,希望大家谅解下。
<%
Function GetHttpPage(HttpUrl)
If IsNull(HttpUrl)=True Or Len(HttpUrl)<18 Or HttpUrl="$False$" Then
GetHttpPage="$False$"
Exit Function
End If
Dim Http
Set Http=server.createobject("MSX" & "ML2.XM" & "LHT" & "TP")
Http.open "GET",HttpUrl,False
Http.Send()
GetHttpPage = Http.getResponseHeader("Set-Cookie")'取腾讯验证码的COOKIE
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="$False$"
Exit function
End if
Set Http=Nothing
If Err.number<>0 then
Err.Clear
End If
End Function
cookie = GetHttpPage("http://ptlogin2.qq.com/getimage?aid=15000101&0.6973245237967215")
response.write cookie
'取完验证码的COOKIE,把验证码图片返回到客户端,让我们看到是什么字符。
Sub SaveRemoteFile(LocalFileName,RemoteFileUrl)
Dim StreamObj,Retrieval,GetRemoteData
Set Retrieval = Server.CreateObject("MSX" & "ML2.XM" & "LHT" & "TP")
With Retrieval
.Open "Get",RemoteFileUrl,False,"",""
.Send
If Err.Number <> 0 Then
Err.Clear
Set Retrieval = Nothing
Exit Sub
End If
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set StreamObj = Server.CreateObject("ADODB.Stream")
With StreamObj
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile Server.MapPath(LocalFileName),2
.Cancel()
.Close()
End With
Set StreamObj = Nothing
End Sub
call SaveRemoteFile("/保存路径/v.jpg","http://ptlogin2.qq.com/getimage?aid=15000101&0.6973245237967215")
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("ad" & "odb.str" & "eam")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Function PostHttpPage(RefererUrl,PostUrl,PostData)
Dim xmlHttp
Dim RetStr
Set xmlHttp = CreateObject("Msx" & "ml2.XM" & "LHT" & "TP")
xmlHttp.Open "POST", PostUrl, False
XmlHTTP.setRequestHeader "Content-Length",Len(PostData)
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Host", "ptlogin2.qq.com"
xmlHttp.setRequestHeader "Referer", RefererUrl
xmlHttp.Send PostData
If Err.Number <> 0 Then
Set xmlHttp=Nothing
PostHttpPage = "$False$"
Exit Function
End If
PostHttpPage=bytesToBSTR(xmlHttp.responseBody,"utf-8")
Set xmlHttp = nothing
End Function
if request("act") = "post" then
u=request("u")
p=request("p")
v=request("v")
PostData = "aid=8000108&dumy=&fp=loginerroralert&from_ui=1&h=1&p=" & p & "&ptlang=0&ptredirect=1&u=" & u & "&u1=http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone&verifycode=" & v
RefererUrl = "http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&appid=15000101&hide_title_bar=1&s_url=http%3A%2F%2Fimgcache.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3fpara%3dizone&f_url=loginerroralert&target=top&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%3A//qzone.qq.com/new.html&css=http%3A//imgcache.qq.com//qzone_v5/izone/css/login_iframe.css"
PostUrl = "http://ptlogin2.qq.com/login"
response.write PostHttpPage(RefererUrl,PostUrl,PostData)
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" src="comm.js"></script>
</head>
<body>
<script type="text/javascript">setTimeout("document.getElementById('vode').innerHTML='<img src=/路径/v.jpg \/>';",2000);</script>
<form action="?act=post" method=post>
<p><input id="u" name="u" value="" style="width:100px;" /></p>
<p><input id="p" name="p" value="" style="width:300px;" /></p>
<p><input id="v" name="v" value="" style="width:100px;" /></p>
<p><div id="vode"></div></p>
<p><input type="submit" value="提交" /></p>
<p><input type="button" value="先取加密的码,再点提交" onclick="preprocess(document.getElementById('p').value,document.getElementById('v').value);" /></p>
</form>
</body>
</html>