I tried to find on Internet as there is big problem with their API. Lack of documentation = can't implement it without super dooper experience in VB.NET (and I'm pretty new)...

Any one used it ? All codes found all around internet are not working (VB2008/VB2010), their support also do not respond on my emails :///


Any one can help me with that ? I can use any captcha service (doesn't matter to me), I just want implement in my software :/

THANKS IN ADVANCE.

Thanks but:

Error	8	'BeginIni' is not a member of 'System.ComponentModel.ISupportInitialize'.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	45	9	WindowsApplication2
Error	3	'Class' statement must end with a matching 'End Class'.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	4	1	WindowsApplication2
Error	7	'cmdDraw' is already declared as 'Friend WithEvents cmdDraw As System.Windows.Forms.Button' in this class.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	38	23	WindowsApplication2
Error	4	'components' is already declared as 'Private components As System.ComponentModel.IContainer' in this class.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	30	13	WindowsApplication2
Error	5	'picCaptcha' is already declared as 'Friend WithEvents picCaptcha As System.Windows.Forms.PictureBox' in this class.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	35	23	WindowsApplication2
Error	2	'Private Sub InitializeComponent()' has multiple definitions with identical signatures.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.Designer.vb	24	17	WindowsApplication2
Error	1	'Protected Overrides Sub Dispose(disposing As Boolean)' has multiple definitions with identical signatures.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.Designer.vb	7	29	WindowsApplication2
Error	6	'txtSource' is already declared as 'Friend WithEvents txtSource As System.Windows.Forms.TextBox' in this class.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	36	23	WindowsApplication2
Error	9	Name 't' is not declared.	C:\Users\Gaming\AppData\Local\Temporary Projects\WindowsApplication2\Form1.vb	45	81	WindowsApplication2

Same on VB2010/VB2008.. All tutorials are not working for me (beside those which I have in VB2010 books, they all even complex are working fine, but 99% of what I found on internet is not working)...

Did you check it ? Is it working for you ???

Hi,

well it is pretty impressive, I don't know what you changed, but it is really nice. Thanks I will keep in mind, only there is one problem, I'm looking for api for DEcaptchers so software can recognize that kind of captcha.

Any way I found pretty ready example only problem is:

Error 2 Reference to a non-shared member requires an object reference. J:\VB.NET\Projects\DeCaptcherAPI\Form1.vb 4 38 DeCaptcherAPI


It seems that it is easy thing to correct, but can you tell me what to do so I can learn what's wrong ?


form1.vb

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dr As DecaptcherResult = DecaptcherAPI.GetCaptchaSolved(Me.WebBrowser1.Document.GetElementById("captcha_image").GetAttribute("src"))
    End Sub
End Class

DecaptcherAPI.VB

Imports System.Net
Imports System.Text
Imports System.IO

Public Class DecaptcherAPI
    Private Uri As String = "http://decaptcher.com/poster/"

    Private username As String = "SNIP"
    Private password As String = "SNIP"

    Public Sub New()
    End Sub

    Public Sub New(ByVal _username As String, ByVal _password As String)
        username = _username
        password = _password
    End Sub

    Public Function GetCaptchaSolved(ByVal FileUrl As String) As DecaptcherResult
        Dim request As HttpWebRequest = CType(WebRequest.Create(FileUrl), HttpWebRequest)

        request.Method = "GET"

        Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)
        Dim requestStream As Stream = response.GetResponseStream

        Dim streamLength As Integer = Convert.ToInt32(response.ContentLength)
        Dim fileData As Byte() = New Byte(Convert.ToInt32(streamLength)) {}
        requestStream.Read(fileData, 0, streamLength)
        requestStream.Close()
        Return GetCaptchaSolved(fileData)

        Return GetCaptchaSolved(fileData)
    End Function


    Public Function GetCaptchaSolved(ByVal File As Byte()) As DecaptcherResult
        Dim request As HttpWebRequest = CType(WebRequest.Create(Uri), HttpWebRequest)

        request.Method = "POST"
        request.KeepAlive = True

        Dim boundary As String = "-------------------------" + DateTime.Now.Ticks.ToString("x")
        Dim header As String = vbCrLf & "--" + boundary + vbCrLf
        Dim footer As String = vbCrLf & "--" + boundary + vbCrLf

        request.ContentType = String.Format("multipart/form-data; boundary={0}", boundary)

        Dim contents As StringBuilder = New StringBuilder()
        contents.Append(vbCrLf)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""function""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append("picture2")

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""username""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(username)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""password""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(password)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""pict_to""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append("0")

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""pict_type""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append("0")

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""pict""; filename=""Untitled.jpg""" + vbCrLf)
        contents.Append("Content-Type: image/jpeg" + vbCrLf)
        contents.Append(vbCrLf)

        Dim BodyBytes As Byte() = Encoding.UTF8.GetBytes(contents.ToString())
        Dim footerBytes As Byte() = Encoding.UTF8.GetBytes(footer)

        request.ContentLength = BodyBytes.Length + File.Length + footerBytes.Length

        Dim requestStream As Stream = request.GetRequestStream()
        requestStream.Write(BodyBytes, 0, BodyBytes.Length)
        requestStream.Write(File, 0, File.Length)
        requestStream.Write(footerBytes, 0, footerBytes.Length)
        requestStream.Flush()
        requestStream.Close()


        Dim ret As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd

        Try

            Return New DecaptcherResult(ret.Split("|")(0), ret.Split("|")(1), ret.Split("|")(2), ret.Split("|")(3), _
                                        ret.Split("|")(4), ret.Split("|")(5))
        Catch ex As Exception
        End Try

    End Function

    Public Function ClaimBad(ByVal dr As DecaptcherResult) As DecaptcherResult
        Dim request As HttpWebRequest = CType(WebRequest.Create(Uri), HttpWebRequest)

        request.Method = "POST"
        request.KeepAlive = True

        Dim boundary As String = "-------------------------" + DateTime.Now.Ticks.ToString("x")
        Dim header As String = vbCrLf & "--" + boundary + vbCrLf
        Dim footer As String = vbCrLf & "--" + boundary + vbCrLf

        request.ContentType = String.Format("multipart/form-data; boundary={0}", boundary)

        Dim contents As StringBuilder = New StringBuilder()
        contents.Append(vbCrLf)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""function""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append("picture_bad2")

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""username""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(username)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""password""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(password)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""major_id""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(dr.MajorID)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""minor_id""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(dr.MinorID)

        Dim BodyBytes As Byte() = Encoding.UTF8.GetBytes(contents.ToString())
        Dim footerBytes As Byte() = Encoding.UTF8.GetBytes(footer)

        request.ContentLength = BodyBytes.Length + footerBytes.Length

        Dim requestStream As Stream = request.GetRequestStream()
        requestStream.Write(BodyBytes, 0, BodyBytes.Length)
        requestStream.Write(footerBytes, 0, footerBytes.Length)
        requestStream.Flush()
        requestStream.Close()

        Dim ret As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd

        Return New DecaptcherResult(ret.Split("|")(0), ret.Split("|")(1), ret.Split("|")(2), ret.Split("|")(3), _
                                    ret.Split("|")(4), ret.Split("|")(5))

    End Function

    Public Function GetBalance() As String
        Dim request As HttpWebRequest = CType(WebRequest.Create(Uri), HttpWebRequest)

        request.Method = "POST"
        request.KeepAlive = True

        Dim boundary As String = "-------------------------" + DateTime.Now.Ticks.ToString("x")
        Dim header As String = vbCrLf & "--" + boundary + vbCrLf
        Dim footer As String = vbCrLf & "--" + boundary + vbCrLf

        request.ContentType = String.Format("multipart/form-data; boundary={0}", boundary)

        Dim contents As StringBuilder = New StringBuilder()
        contents.Append(vbCrLf)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""function""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append("balance")

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""username""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(username)

        contents.Append(header)
        contents.Append("Content-Disposition: form-data; name=""password""" & vbCrLf)
        contents.Append(vbCrLf)
        contents.Append(password)

        Dim BodyBytes As Byte() = Encoding.UTF8.GetBytes(contents.ToString())
        Dim footerBytes As Byte() = Encoding.UTF8.GetBytes(footer)

        request.ContentLength = BodyBytes.Length + footerBytes.Length

        Dim requestStream As Stream = request.GetRequestStream()
        requestStream.Write(BodyBytes, 0, BodyBytes.Length)
        requestStream.Write(footerBytes, 0, footerBytes.Length)
        requestStream.Flush()
        requestStream.Close()

        Dim ret As String = New StreamReader(request.GetResponse.GetResponseStream).ReadToEnd

        Return ret
    End Function

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class

Public Class DecaptcherResult

    Public Sub New()
    End Sub

    Public Sub New(ByVal resultCode As String, ByVal majorID As String, ByVal minorID As String, ByVal type As String, _
                   ByVal timeout As String, ByVal text As String)
        Me._ResultCode = resultCode
        Me._MajorID = majorID
        Me._MinorID = minorID
        Me._Type = type
        Me._Timeout = timeout
        Me._Text = text
    End Sub

    Public Property ResultCode() As String
        Get
            Return _ResultCode
        End Get
        Set(ByVal value As String)
            _ResultCode = value
        End Set
    End Property

    Public Property MajorID() As String
        Get
            Return _MajorID
        End Get
        Set(ByVal value As String)
            _MajorID = value
        End Set
    End Property

    Public Property MinorID() As String
        Get
            Return _MinorID
        End Get
        Set(ByVal value As String)
            _MinorID = value
        End Set
    End Property

    Public Property Type() As String
        Get
            Return _Type
        End Get
        Set(ByVal value As String)
            _Type = value
        End Set
    End Property

    Public Property Timeout() As String
        Get
            Return _Timeout
        End Get
        Set(ByVal value As String)
            _Timeout = value
        End Set
    End Property

    Public Property Text() As String
        Get
            Return _Text
        End Get
        Set(ByVal value As String)
            _Text = value
        End Set
    End Property


    Private _ResultCode As String
    Private _MajorID As String
    Private _MinorID As String
    Private _Type As String
    Private _Timeout As String
    Private _Text As String
End Class

As you can see

GetCaptchaSolved

Is a public member function.. So when you want to access it without creating an instance of that class u will get error....

2 possible way to solve it..

1. first create an object then use the GetCaptchaSolved function
2. Declare GetCaptchaSolved as shared function, so that u can access it without creating any objects....

Hope you understand...........

Hi,

Thanks but second way isn't working as I'm getting errors in decaptcherAPI.vb, and to be honest when I tries Dim... for 1st way it still giving me same error :/

Show me your code where u getting error...

Hi,

Well I tried to dim d as ... but it doesn't working :/// I don't understand why it is worked on example code from MS book but here it's not :///

Here is a code:

Dim DecaptcherAPI.GetCaptchaSolved() as object

Error 2 End of statement expected. J:\VB.NET\Projects\DeCaptcherAPI\Form1.vb 6 26 DeCaptcherAPI

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.