[HELP] reCaptcha by HttpWebRequest

Discussion in 'Visual Basic .NET' started by carlx, Mar 16, 2012.

  1. carlx

    carlx Registered Member

    Joined:
    Dec 28, 2008
    Messages:
    95
    Likes Received:
    88
    Hi Guys,

    I am looking for a working example of getting a reCaptcha image by HttpWebRequest.

    I don't need an all singing, all dancing example, but something that works and that i can work with.

    All my searches so far has found outdated examples.

    Anybody willing to help you can PM me.

    Cheers.
     
  2. gimme4free

    gimme4free Executive VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,950
    Likes Received:
    1,949
    Code:
    			Dim ChallengeKey As String = GetBetween(Content, "https://www.google.com/recaptcha/api/challenge?k=", """")
                Dim CaptchaSID As String = GetBetween(Content, "id=""edit-captcha-sid"" value=""", """")
                Dim CaptchaToken As String = GetBetween(Content, "id=""edit-captcha-token"" value=""", """")
    			Dim ChallengeURL As String = "https://www.google.com/recaptcha/api/challenge?k=" & ChallengeKey
                Try
                    Content = a_Process.Return_Content(ChallengeURL)
                Catch ex As Exception
                    SendMessage("Error Retrieving Captcha ChallengeURL: " & ex.Message)
                    Continue While
                End Try
    			 ' Scrape Challenge Key
                ChallengeKey = GetBetween(Content, "challenge : '", "'")
                ' Confirm ChallengeKey Exists
                If ChallengeKey = "" Then
                    SendMessage("Failed To Scrape Challenge Key (2), See Error Log")
                    If AdminMode = True Then Log_Show_Error(Content)
                    Exit While
                End If
    			Dim CaptchaImageURL As String = "https://www.google.com/recaptcha/api/image?c=" & ChallengeKey
    			' Display Captcha Image To User For Entry
                CaptchaForm.PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(CaptchaImageURL)))
                CaptchaForm.ShowDialog()
                CaptchaAnswer = CaptchaForm.TextBox1.Text
                If CaptchaAnswer = "" Then
                    SendMessage("Captcha Answer Was Not Provided, Ending Process")
                    Exit While
                End If
    a_Process is my webrequest class object which uses the same cookie container throughout.
     
    • Thanks Thanks x 1
  3. carlx

    carlx Registered Member

    Joined:
    Dec 28, 2008
    Messages:
    95
    Likes Received:
    88
    Thank you very much, thanks and +rep given as a small way of repaying your kindness.