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

VB.NET ~ Are captcha's possible with webclient?

Discussion in 'Visual Basic .NET' started by simpleonline1234, Feb 20, 2012.

  1. simpleonline1234

    simpleonline1234 Junior Member

    Joined:
    Jan 26, 2010
    Messages:
    169
    Likes Received:
    13
    I am looking into getting away from using the web browser component to create applications but one of the good things about the web browser component was that it could use Javascript to pull a captcha into a picturebox for the user to solve.

    I am moving on to using the webclient but I'm not sure if the webclient would be able to download a captcha picture into a picturebox for the user to solve.
     
  2. Cynikal

    Cynikal Newbie

    Joined:
    May 11, 2010
    Messages:
    32
    Likes Received:
    8
    Short Answer: No.

    It took me awhile to figure out how to get the captcha.

    You have to use the code behind webclient (system.net.htmlclient or whatever)

    then downloadstring (the site with the captcha)

    then, regex the captcha image location.

    then download the image itself to your HD

    then either upload that image to a captcha service, or display it for them to solve.

    ----

    Once the image is initially displayed, you can't reopen it(from the web)...

    So you can't display the page, get the url of the image, then download it... you just have to know what it is..before it displays.
     
  3. healzer

    healzer Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Jun 26, 2011
    Messages:
    2,363
    Likes Received:
    1,966
    Gender:
    Male
    Occupation:
    Marketing automation tools
    Location:
    Somewhere in Europe
    Home Page:
    Why no?
    I do it... works fine
     
  4. Cynikal

    Cynikal Newbie

    Joined:
    May 11, 2010
    Messages:
    32
    Likes Received:
    8
    i was thinking web browser control, which is possible too, but makes things difficult
     
  5. simpleonline1234

    simpleonline1234 Junior Member

    Joined:
    Jan 26, 2010
    Messages:
    169
    Likes Received:
    13
    So basically you can't grab captcha using the web client?
     
  6. hatemachine

    hatemachine Regular Member

    Joined:
    Jan 14, 2011
    Messages:
    271
    Likes Received:
    1,138
    The captcha url is located in the html source, so just parse the source for the url, open it and download the image; then just display it in a picturebox, you don't need to save it to hd. If it's recaptcha, you'll have to request it yourself.
     
  7. simpleonline1234

    simpleonline1234 Junior Member

    Joined:
    Jan 26, 2010
    Messages:
    169
    Likes Received:
    13
    Thanks hatemachine....yeah its actually recaptcha that I am trying to get..what do you mean when you say "request it yourself".

    I can enter the link given in the HTML code of the page and it directs me to the recaptcha.com website where I can enter the challenge manually.


    [​IMG]

    When I enter the result correctly it gives me the result "Your answer was correct. Please copy and paste the text in this text box into the box below."

    How do I get that text back to the website to prove my code was correct? Wouldn't the code they have be different from the one I just ran manually? That is where I am getting really confused.

    [​IMG]

    Thanks guys
     
    Last edited: Mar 6, 2012
  8. Cynikal

    Cynikal Newbie

    Joined:
    May 11, 2010
    Messages:
    32
    Likes Received:
    8
    You would use regex to get the information you need, then submit a post with the information.
     
  9. simpleonline1234

    simpleonline1234 Junior Member

    Joined:
    Jan 26, 2010
    Messages:
    169
    Likes Received:
    13
    Hey thanks to all who helped on this hair pulling journey to grabbin captcha during weg req so I can say that "yes" it is very possible and doable to work this.

    I will post the working code on how to was all done once I get everything in working order.

    But in simple -
    1- send request to website
    2 -scrape to get the challenge api
    3 -Run the challenge key
    4- combine the api with the challenge and run this to your pictureboz

    Thanks all that helped.
     
  10. weedsmoker

    weedsmoker Junior Member

    Joined:
    May 2, 2011
    Messages:
    190
    Likes Received:
    79
    Well, this would work well for captchas when captcha is defined with image url. Example:

    Code:
    http://www.google.com/recaptcha/learnmore
    Go to this url, copy captcha image in new tab, both captchas are same.

    So you'll only need to parse captcha url, but what to do when you have fixed/static captcha image url?
    Example:

    Code:
    http://brucesprivatelab.com/phpdug/signup.php
    Go to this url, copy captcha image in new tab, captchas are different.

    1. request form (to get captcha url)
    2. fetch captcha (captcha loaded)
    3. solve fetched captcha
    4. try to submit form (captcha loaded again) with solved captcha

    This won't work because captcha have static url and changes on every reload, so step 2 captcha != step 4 captcha. You need to deal with session cookies. So you'll need to:

    1. request form (to get captcha url)
    2. fetch captcha
    3. store cookies or save them to file
    3. solve fetched captcha
    4. request form
    5. load stored/saved cookies
    6. submit form with solved captcha

    I hope someone finds this useful, because this has given me some trouble awhile ago.
     
  11. accelerator_dd

    accelerator_dd Jr. VIP Jr. VIP Premium Member

    Joined:
    May 14, 2010
    Messages:
    2,441
    Likes Received:
    1,005
    Occupation:
    SEO
    Location:
    IM Wonderland
    It really depends on the captcha provider. I have found one that was using javascript to pull the image and a hidden field. So what it was actually doing was matching the hidden value with the image result. Once I figured this out, i took it out of the equation by making a separate call to get a hidden code and an image url to decode, then just send that pair as if it was assigned to me.

    Worked like a charm.