Jump to content

  •  

  • iBotModz CBox


    Tutorial info Visit support topic

    • Added on: Oct 05 2009 06:01 AM
    • Views: 3204
     


    C# Loading reCaptcha into a imagebox

    A simple tutorial on grabbing the reCaptcha image from an HTML page, to pull into a imageBox.

    Posted by iBotPeaches on Oct 05 2009 06:01 AM
    I went through about a week of making bots, and when you make a bot you have to be able to download the image from the CAPTCHA (or in this case ReCaptcha) so you can display it to the user to be entered, or send it to decaptcher for them to crack it.

    If you don't understand what that meant, this tutorial isn't for you. I'm just going to walk through how to pull the image from the ReCaptcha field. This tutorial assumes you have a hidden web browser in which you are using to navigate some page. This is assuming the basic GetElementByID doesn't work, since its generated dynamically per pageload.

    code2.png


    This is our code.

    Were using a foreach loop to go through every image in the Webbrowser
    foreach (HtmlElement images in webBrowser1.Document.Images)

    Now were doing a quick if statement to see if that image path has the URL of the recaptcha in it.
    if (images.GetAttribute("src").Contains("http://api.recaptcha.net/image?c="))

    GetAttribute allows you to lots of things with a specific HTMLElement (in this case images)

    If it matches a simple line will dump that URL to an imagebox.
    string url = images.GetAttribute("src");

    Then dump the variable url to your imagebox. Ignore the code tCount++; in there, it was part of that application.

    So it starts as a picture box.
    pic1.png

    Assuming you grabbed the URL of the image correctly, it should show the image like so.
    pic3.png

    Powered by Tutorials 1.5.0 © 2024, by Michael McCune