酷酷七友软件定做 酷酷七友软件

软件开发

联通验证码识别

联通验证码识别...

基本情况:中国联通官网的验证码,固定位置,固定大小,无干扰

获取地址:http://ecard.10010.com/getImage.jsp

基本思路是为每个数字建模,然后逐像素点对比,当匹配度最高的数字即为结果,如果识别错误则再次获取后识别。

程序采用WebBrowser1+自动填表+自动点击的方式完成,部分代码如下:

view plaincopy to clipboardprint?
'################################处理自动填表################################  
If URL = "http://pay.10010.com/payFeeOnline/payFeeOnlineInit.action" And Form1.Tag = "0" Then 
 
    '获取验证码图像,开始解析  
    Command1.Caption = "正在获取验证码,请稍侯..." 
    Dim Buff() As Byte 
    Inet1.URL = "http://ecard.10010.com/getImage.jsp
    Buff() = Inet1.OpenURL(, icByteArray)  
      
    If UBound(Buff()) < 100 Then GoTo error1  
      
    With Picture1  
        .Picture = PictureFromBits(Buff())  
        .PaintPicture .Picture, 0, 0, 700, 400, 0, 0, .ScaleWidth, .ScaleHeight  
    End With 
    DoEvents  
 
    '识别验证码  
    Call GetCode  
 
   Command1.Caption = "订单生成中..." 
      
    tyty = Split(Get_Data, "*")                   '充值号码,每次一个  
    If tyty(2) <> "1" Then tyty(1) = CStr(CSng(tyty(1)) * CSng(tyty(2))) '金额=金额*数量  
      
    WebBrowser1.Document.All("payFeeOnlineInfo.productNO").Value = tyty(0)  
    WebBrowser1.Document.All("payFeeOnlineInfo.productNOAgain").Value = tyty(0)  
    WebBrowser1.Document.All("payFeeOnlineInfo.payFee").Value = tyty(1)  
      
    WebBrowser1.Document.All("payFeeOnlineInfo.checkCode").Value = Text1.Text  
 
    '提交表单  
    WebBrowser1.Document.All("submit0").Click  
    Command1.Caption = "跳向确认订单!" 
      
    Form1.Tag = "1" 
      
    Exit Sub 
 
error1:  
 
    Form1.Tag = "0" 
 
End If 
'################################处理自动填表################################
If URL = "http://pay.10010.com/payFeeOnline/payFeeOnlineInit.action" And Form1.Tag = "0" Then

    '获取验证码图像,开始解析
    Command1.Caption = "正在获取验证码,请稍侯..."
    Dim Buff() As Byte
    Inet1.URL = "http://ecard.10010.com/getImage.jsp"
    Buff() = Inet1.OpenURL(, icByteArray)
   
    If UBound(Buff()) < 100 Then GoTo error1
   
    With Picture1
        .Picture = PictureFromBits(Buff())
        .PaintPicture .Picture, 0, 0, 700, 400, 0, 0, .ScaleWidth, .ScaleHeight
    End With
    DoEvents

    '识别验证码
    Call GetCode

   Command1.Caption = "订单生成中..."
   
    tyty = Split(Get_Data, "*")                   '充值号码,每次一个
    If tyty(2) <> "1" Then tyty(1) = CStr(CSng(tyty(1)) * CSng(tyty(2))) '金额=金额*数量
   
    WebBrowser1.Document.All("payFeeOnlineInfo.productNO").Value = tyty(0)
    WebBrowser1.Document.All("payFeeOnlineInfo.productNOAgain").Value = tyty(0)
    WebBrowser1.Document.All("payFeeOnlineInfo.payFee").Value = tyty(1)
   
    WebBrowser1.Document.All("payFeeOnlineInfo.checkCode").Value = Text1.Text

    '提交表单
    WebBrowser1.Document.All("submit0").Click
    Command1.Caption = "跳向确认订单!"
   
    Form1.Tag = "1"
   
    Exit Sub

error1:

    Form1.Tag = "0"

End If
 

以上是登陆到联通自动充值页面,填写手机号码,充值金额和验证码之后,生成订单的一个过程。

之后是订单确认,然后转网银支付。

验证码识别部分:

view plaincopy to clipboardprint?
Private Sub GetCode()  
 
'识别=========================  
 
Command1.Caption = "正在识别验证码..." 
 
    t1 = "" 
    t2 = "" 
    t3 = "" 
    t4 = "" 
      
    Dim ty(9)  
    ty(0) = "00001111111100011111111111011100000000111000000000011000000000011100000000001110000000111101111111111100" 
    ty(1) = "00000000000010000000000001010000000011111111111111111011111111001110000000000111000000000010000000000000" 
    ty(2) = "00000000001110100000011101110000001100110000001110011000001100001100000110000111111110000011111110000000" 
    ty(3) = "00000000000110100001000001110000100000111000010000011000001000001100001111111111111101111101111100000000" 
    ty(4) = "00000001110000000001111000000001101100000000110110000000110011000001110001111111111111111111111111111000" 
    ty(5) = "00111100000111111110000001110001000000110000100000111000011000110100000111110010000011111001000000111000" 
    ty(6) = "00001111111100011001000001011101100000101110110000011100010000001100001000001110000110001101000001111110" 
    ty(7) = "00000000000011000000000111100000000011110000001111101000001111000100001100000010111100000001111100000000" 
    ty(8) = "00111001111110111110111011110001110000110000010000011000001000001100001110011110000111001111111111111110" 
    ty(9) = "00001100000110111111000001011100110000111000001000011000000100011100000111111010000011111101111111011100" 
      
 
'111111111  
      
Dim flag(10)  
 
For i = 4 To 11  
    For j = 8 To 20  
        If Picture1.Point(i, j) < &H200000 Then 
            t1 = t1 & "1" 
        Else 
            t1 = t1 & "0" 
        End If 
 
    Next j  
 Next i  
   
Text1.Tag = 0  
For M = 0 To 9  
    For N = 0 To Len(t1)  
        If Mid(t1, N + 1, 1) = Mid(ty(M), N + 1, 1) Then 
            flag(M) = flag(M) + 1  
        End If 
      
    Next N  
      
    If flag(M) > CSng(Text1.Tag) Then 
        Text1.Tag = flag(M)  
        ty1 = M  
    End If 
 
Next M  
   
              
 '2222222222222s  
 For i = 14 To 21  
    For j = 8 To 20  
 
        If Picture1.Point(i, j) < &H200000 Then 
            t2 = t2 & "1" 
        Else 
            t2 = t2 & "0" 
        End If 
   
    Next j  
 Next i  
 
Text1.Tag = 0  
For M = 0 To 9  
flag(M) = 0  
    For N = 0 To Len(t2)  
        If Mid(t2, N + 1, 1) = Mid(ty(M), N + 1, 1) Then 
            flag(M) = flag(M) + 1  
        End If 
      
   Next N  
      
 If flag(M) > CSng(Text1.Tag) Then 
    Text1.Tag = flag(M)  
    ty2 = M  
 
 End If 
 
Next M  
 
 '33333333333  
For i = 24 To 31  
    For j = 8 To 20  
        If Picture1.Point(i, j) < &H200000 Then 
            t3 = t3 & "1" 
        Else 
            t3 = t3 & "0" 
        End If 
   
    Next j  
 Next i  
 
Text1.Tag = 0  
 
For M = 0 To 9  
flag(M) = 0  
    For N = 0 To Len(t3)  
        If Mid(t3, N + 1, 1) = Mid(ty(M), N + 1, 1) Then 
            flag(M) = flag(M) + 1  
        End If 
      
   Next N  
      
 If flag(M) > CSng(Text1.Tag) Then 
    Text1.Tag = flag(M)  
    ty3 = M  
 
 End If 
 
Next M  
   
 '444444  
For i = 34 To 41  
    For j = 8 To 20  
 
        If Picture1.Point(i, j) < &H200000 Then 
            t4 = t4 & "1" 
        Else 
            t4 = t4 & "0" 
        End If 
   
    Next j  
Next i  
 
 
Text1.Tag = 0  
For M = 0 To 9  
flag(M) = 0  
    For N = 0 To Len(t4)  
        If Mid(t4, N + 1, 1) = Mid(ty(M), N + 1, 1) Then 
            flag(M) = flag(M) + 1  
        End If 
      
   Next N  
      
 If flag(M) > CSng(Text1.Tag) Then 
    Text1.Tag = flag(M)  
    ty4 = M  
 
 End If 
   
          
 
Next M  
 
Text1.Text = ty1 & ty2 & ty3 & ty4  
 
 
End Sub 

 

Powered By Error Q:302777528