| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 803 人关注过本帖
标题:vb登录空间
只看楼主 加入收藏
醉红尘
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-3-12
结帖率:100%
收藏
 问题点数:0 回复次数:0 
vb登录空间
我写一个小程序,是登录QQ空间的。窗体上有三个文本框,一个是QQ号,一个是QQ密码,一个验证码,一个picturebox显示验证码,一个inet,一个downloader,一个webBrowser用来显示网页
输入QQ号和QQ密码,再输入验证码,正确的话就打开QQ空间。
以下是我的代码
程序代码:
'首先,根据QQ号获取验证码,
Public Function GetCode(QQ As String, Ine As Inet, DownLoad As Downloader, Picture1 As PictureBox) As Boolean
    Dim strtmp As String
    Dim Url As String
    Dim B() As Byte
    Dim Yzm As String
    Dim str1, str2 As String
On Error GoTo errfind
    YZMstr = ""
    ptunit = ""
    GetCode = False
    
    Url = "http://check.ptlogin2." & QQ & "&appid=549000912&js_ver=10071&js_type=1&login_sig=-V4T0qXVJwIkJtjoh4KJ-1kOgTtU9gWcUJnKKTl8*v5u-rh*1LVoA8pQv9f5l2iM&u1=http%3A%2F%2Fqzs." & GetRnd(17)

Ine.Execute Url, "GET", , "Referer: */*"
    Do While Ine.StillExecuting
        DoEvents
    Loop
    
    B = Ine.GetChunk(0, icByteArray)
    strtmp = Utf8ToUnicode(B)
    
    If Len(strtmp) = 0 Then
        '验证码获取失败
        Msg = "验证码获取失败"
        GetCode = False
    Else
        '验证码获取成功
        PtUin = Mid(strtmp, InStr(strtmp, "\x"), 32)
        If InStr(strtmp, "!") > 0 Then  '自动获取
            YZMstr = Mid(strtmp, InStr(strtmp, "!"), 4)
            Picture1.Picture = Nothing
            Picture1.Print "免验证"
            GetCode = True
        Else    '手动获取
            str1 = InStr(strtmp, "ptui_checkVC('1','")
            str2 = InStr(strtmp, "','\x") '"','\x00\x00\x00\x00\x5e\xc1\xfe\x85');")
            str1 = Mid(strtmp, str1, str2 - str1)
            YZMstr = Replace(str1, "ptui_checkVC('1','", "")
            If Len(YZMstr) = 0 Then
                Msg = "手动获取验证码失败"
                GetCode = False
                Exit Function
            Else
                '下载验证码
                DownLoad.BeginDownload "http://captcha." & GetRnd(17) & "&uin=" & QQ & "&vc_type=" & YZMstr, App.path & "\yzm.jpeg"

                Picture1.Picture = Nothing
                Picture1.Picture = LoadPicture(App.path & "\yzm.jpeg")
                GetCode = True
            End If
            
        
        End If
        
    End If
    
    Exit Function
errfind:
    
    GetCode = False
End Function

'然后是登录
'登录qq空间
Public Function QQLogin(QQ As String, Pwd As String, Vcode As String, Ine As Inet, Webb As WebBrowser)
    Dim PwdStr As String
    Dim B() As Byte
    Dim Url As String
    Dim strtmp, Msg1, Msg2 As String
    
    
On Error GoTo errfind
    '----------------------------------------------------------初始化数据

    QQUin = Trim(QQUin)
    Vcode = Trim(Vcode)
    '----------------------------------------------------------加密数据
    
    B = Sta2Arr(MD5_S(Pwd) & PtUin)
    PtPwd = MD5_B(B)
    PwdStr = MD5_S(PtPwd & UCase(Vcode))
    

    '----------------------------------------------------------开始登录

    Url = "http://ptlogin2." & QQ & "&p=" & PwdStr & "&verifycode=" & Vcode & "&aid=549000912&u1=http%3A%2F%2Fqzs." & _            "3Dreload&h=1&ptredirect=0&ptlang=2052&from_ui=1&dumy=&low_login_enable=0&regmaster=&fp=loginerroralert&action=5-25-1395363680734&mibao_css=&t=1&g=1&js_ver=10072&js_type=1&login_sig=0I-a1UyIm6ABfOzt6u18Q*RoScwY4bnAYrKb73MhxLnQe3oQU0BNS51k*g4v93yG&pt_rsa=0&pt_3rd_aid="
      
    
    Debug.Print Url
    Ine.Execute Url ', "GET", , "Accept: */*"

    Do While Ine.StillExecuting
        DoEvents
    Loop
    
    B = Ine.GetChunk(0, icByteArray)
    strtmp = Trim(Replace(Utf8ToUnicode(B), Chr(0), ""))
    
    Debug.Print strtmp
    If Len(strtmp) = 0 Then
        Msg = "加载失败"
    Else
       If InStr(strtmp, "ptuiCB('1','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('1','0','','0','")
            Msg2 = InStr(strtmp, "', '" & QQ & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('1','0','','0','", "")
    
            'Msg = "系统繁忙,请稍后再试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('2','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('2','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('2','0','','0','", "")
            
'            Msg = "已经过期的QQ号"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('3','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('3','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('3','0','','0','", "")
            
            'Msg = "您输入的密码有误,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('4','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('4','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('4','0','','0','", "")
            
'            Msg = "您输入的验证码有误,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('5','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('5','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('5','0','','0','", "")
        
'            Msg = "校验失败"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('6','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('6','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('6','0','','0','", "")
            
'            Msg = "密码错误,如果您刚修改过密码,请稍后再登录"
            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('7','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('7','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('7','0','','0','", "")
            
'            Msg = "您输入有误,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('8','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('8','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('8','0','','0','", "")
            
'            Msg = "您的IP输入错误的次数过多,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('9','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('9','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('9','0','','0','", "")
            
'            Msg = "您的账号不正确,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('10','0','','0','") > 0 Then
            Msg1 = InStr(strtmp, "ptuiCB('10','0','','0','")
            Msg2 = InStr(strtmp, "', '" & Trim(QQ) & "');")
            Msg = Mid(strtmp, Msg1, Msg2 - Msg1)
            Msg = Replace(Msg, "ptuiCB('10','0','','0','", "")
            
'            Msg = "您输入的账号不正确,请重试"
'            Exit Function
        ElseIf InStr(strtmp, "ptuiCB('0','0','") > 0 Then
            Webb.Navigate "http://user.qzone." & QQ                
                Msg = "登录成功" 
            
        End If
    End If
    
    Exit Function
errfind:
    Msg = "异常错误"
    Exit Function
End Function

现在问题出来了,如果 验证码是自动获取的那就没问题,可以正常登录。
要是验证码不是自动获取的,是用手动输入的,当然输入的验证是正确的,就是图片框里显示的。然后就提示:ptuiCB('4','0','','0','您输入的验证码不正确,请重新输入。

请哪位高手给看看我到底错哪了,我弄了三天了,还是没好,郁闷死了。
跪拜感激……
有不明白 的地方可以加我QQ说,409148370

[ 本帖最后由 醉红尘 于 2014-3-21 11:29 编辑 ]
搜索更多相关主题的帖子: 文本框 QQ密码 登录空间 登录QQ空间 输入验证码 
2014-03-21 11:28
快速回复:vb登录空间
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042245 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved