1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Trouble parsing RECaptcha img URL.

Discussion in 'Visual Basic .NET' started by phrozn, Dec 3, 2013.

  1. phrozn

    phrozn Registered Member

    Joined:
    Aug 17, 2011
    Messages:
    86
    Likes Received:
    18
    Ok so I am in the process of making a bot, and I am having the hardest time pulling the captcha from the HTML.

    The program is using a traditional WebBrowser control.

    I've tried getting it by element tag "img". No luck. I see the image on the browser, but when I have the program list all elements by tag "img" it doesnt even show the img url which I am clearly looking at in the source.

    Any methods for extracting that still work?

    EDIT: READ MY BELOW POST.
     
    Last edited: Dec 3, 2013
  2. phrozn

    phrozn Registered Member

    Joined:
    Aug 17, 2011
    Messages:
    86
    Likes Received:
    18
    OK I actually found the problem I believe. When initiating a chat, the url doesnt technically change. Apparently there is a server side call to initiate a chat. So when the control looks for the images, it still sees the homepage. How can I get around this?
     
  3. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,879
    Likes Received:
    1,931
    All you need is the public key which is visible in the HTML, E.g.

    Code:
    Dim recaptcha_public_key As String = ""
    Dim CaptchaAnswerDetails() As String = GetCaptcha(recaptcha_public_key)
    
    Friend Function GetCaptcha(ByVal recaptcha_public_key As String) As String()
            ' Variables
            Dim CaptchaImageURL As String
            Dim URL As String
            Dim Content As String
            ' Load Challenge URL
            URL = "http://api.recaptcha.net/challenge?k=" & recaptcha_public_key
            Try
                Content = Get_URL(URL)
            Catch ex As Exception
                Throw New Exception("Failed To Load Recaptcha Challenge URL: " & ex.Message)
            End Try
            ' Scrape Challenge Key
            Dim ChallengeKey As String = GetBetween(Content, "challenge : '", "'")
            ' Confirm ChallengeKey Exists
            If ChallengeKey = Nothing Then
                Throw New Exception("Failed To Scrape Challenge Key, Unknown Issue")
            End If
            ' Form Captcha Image URL
            CaptchaImageURL = "http://www.google.com/recaptcha/api/image?c=" & ChallengeKey
            ' Form Array
            Dim Keys() As String = {CaptchaImageURL, ChallengeKey}
            ' Return Captcha Image URL
            Return Keys
        End Function
    Note that you should use your own HTTP process for the GetURL & keep the cookies for the process.
     
    • Thanks Thanks x 1