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

YouTube Captcha Image to Vb.NET project

Discussion in 'YouTube' started by the known, Jul 14, 2011.

  1. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    Hello guys...

    So when you post more than 3 channel comments on YouTube, you'll get a captcha. I want to get that captcha image and view it in a picturebox in a Vb.NET program.

    Here's the html code of the captcha part on YouTube:
    Code:
    <form action="" id="comment_captcha_form" method="post">
    <input type="hidden" name="challenge" value="MUemlAa3Sgnbb1uuJSsFJrGflKXFEflxa_tivSwDmakylPyNEyMU8Q==" id="challenge">
    <input type="hidden" name="comment" id="comment" value="test">
    <input type="hidden" name="view_all_mode" id="view_all_mode" value="False">
    <input type="hidden" name="items_per_page" id="items_per_page" value="10">
    
    <table class="commentsTableFull">
      <tbody><tr>
        <td>
          <strong>You have recently posted several comments.
          <br>
          Enter the text in the image to continue posting.</strong>
        </td>
      </tr>
      <tr>
        <td>
          <input size="16" name="response" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" maxlength="10" value="" type="text" id="response">
          <input type="button" id="comment_entry_submit_button" value="Submit" onclick="add_comment('user_comments', _gel('comment').value, _gel('view_all_mode').value, _gel('items_per_page').value, _gel('challenge').value, _gel('response').value);">
          <a href="#" onclick="document.verificationImg.src='/cimg?c=MUemlAa3Sgnbb1uuJSsFJrGflKXFEflxa_tivSwDmakylPyNEyMU8Q==&'+Math.random();return false"><img name="verificationImg" src="/cimg?c=MUemlAa3Sgnbb1uuJSsFJrGflKXFEflxa_tivSwDmakylPyNEyMU8Q==&0.6778344342019409" align="middle" border="0"></a>
          <div class="formFieldInfo">
            <a href="#" onclick="document.verificationImg.src='/cimg?c=MUemlAa3Sgnbb1uuJSsFJrGflKXFEflxa_tivSwDmakylPyNEyMU8Q==&'+Math.random();return false">Can't read?</a>
          </div>
        </td>
      </tr>
    </tbody></table>
    
    </form>
    I already tried this in VB.Net:
    Code:
    PictureBox1.ImageLocation = WebBrowser1.Document.GetElementById("verificationImg").GetAttribute("src")
    But the problem with all of those Captcha URL's (src's) is, that the captcha cahnges everytime you visit it.
    For example:
    http://www.youtube.com/cimg?c=MUemlAa3Sgnbb1uuJSsFJrGflKXFEflxa_tivSwDmakylPyNEyMU8Q==

    if you refresh the page, you see that the captcha changes everytime. So I DO KNOW how to get the captcha in a picturebox in VB, the only problem is that the captcha in the picturebox is a different one than the captcha in the webbrowser itself in VB (because everytime you visit the link it makes a random new one)...

    So does anybody know any other solution on how to show the YouTube captcha in a picturebox in Vb?

    Thanks in advance.
     
  2. Adam Rock

    Adam Rock Senior Member

    Joined:
    May 13, 2010
    Messages:
    1,069
    Likes Received:
    248
    Location:
    /home/
    make a frame and put whatever is displayed in the frame.
     
  3. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    Lol. Its not that easy.
     
  4. wowhaxor

    wowhaxor Executive VIP Premium Member

    Joined:
    Apr 28, 2007
    Messages:
    2,021
    Likes Received:
    3,353
    Location:
    ?¿?
    Home Page:
    You take a screen capture of that part of the page where the captcha appears, pause the script and make a pop up box with the screen capture and an input field under it with your submit button. Obviously the input field will write to the field on YouTube and the submit button (or whatever you decide to name it) will be tied to the submit button on the captcha form; once you have hit submit you have the script resume.

    Of you can just use decaptcher or some similar service and have it 100% auto.
     
  5. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    Yea, but how to make a screenshot of that captcha part only?
     
  6. ceo140

    ceo140 Newbie

    Joined:
    Jun 29, 2011
    Messages:
    40
    Likes Received:
    3
    browser.CaptureWebPageToFile()
     
  7. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    Please explain it more.
    Cuz it also shouldn't capture the whole webpage, just the captcha...
     
  8. wowhaxor

    wowhaxor Executive VIP Premium Member

    Joined:
    Apr 28, 2007
    Messages:
    2,021
    Likes Received:
    3,353
    Location:
    ?¿?
    Home Page:
    Use pixel coordinates.

    If you insist on doing it manually instead of integrating captcha solving (pay like $1.50 for 1,000 solved captchas and it comes with code to plug into your app - well worth it IMO) just Google for the code and then edit it to fit a YouTube page. Everyone and their mom does this so I'm sure there's like 5 million example snippets out there.
     
  9. DarkoOS

    DarkoOS Newbie

    Joined:
    Feb 8, 2010
    Messages:
    19
    Likes Received:
    6
    Occupation:
    IT Manager
    Location:
    Osijek, Croatia
    Home Page:
    Hello,
    I guess you are using web browser control?

    Try this
    Code:
            Dim broj as Integer = 1 'This is nuber of picture, in WebBrowser control
            Dim doc As mshtml.IHTMLDocument2 = DirectCast(WebBrowser1.Document, mshtml.IHTMLDocument2)
            Dim sobj As mshtml.IHTMLSelectionObject = doc.selection
            Dim body As mshtml.HTMLBody = TryCast(doc.body, mshtml.HTMLBody)
            sobj.empty()
            Dim range As mshtml.IHTMLControlRange = TryCast(body.createControlRange(), mshtml.IHTMLControlRange)
            Dim img As mshtml.IHTMLControlElement = DirectCast(WebBrowser1.Document.Images(broj), mshtml.IHTMLControlElement)
            range.add(img)
            range.[select]()
            range.execCommand("Copy", False, Nothing)
            Dim bimg As New Bitmap(Clipboard.GetImage())
            Me.PictureCaptcha.Image = bimg
    
    I hope it will help you, for me works fine on 20 torrent sites, yahoo mail register also work ;-)

    Darko,
     
  10. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    It gives an error; It can't convert 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument2'

    also, these 2 lines
    WebBrowser1.Document
    WebBrowser1.Document.Images(broj)

    are underlined in green (so there's something wrong).
     
  11. DarkoOS

    DarkoOS Newbie

    Joined:
    Feb 8, 2010
    Messages:
    19
    Likes Received:
    6
    Occupation:
    IT Manager
    Location:
    Osijek, Croatia
    Home Page:
    Hi,

    what version of VB you are using ?
    and important, what version of WebBrowser ??

    i'm using AxSHDoc.AxWebBrowser

    you need this declaration
    Imports System.Web

    and reference to this files:
    AxInterop.SHDocVw.dll
    Interop.SHDocVw.dll
    Microsoft.mshtml.dll

    Darko,
     
  12. wowhaxor

    wowhaxor Executive VIP Premium Member

    Joined:
    Apr 28, 2007
    Messages:
    2,021
    Likes Received:
    3,353
    Location:
    ?¿?
    Home Page:
    You seem fairly new to VB, you need to Google more you're find fixes a lot faster. VB was the first thing I used for coding and you'll find most of the time you're just omitting things or making minor mistakes and a quick G search can find you very similar example code to what you're looking for and solve your problem.

    You should be a pro in just a couple of weeks if you take that approach.
     
  13. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    I am already googling a lot, and searching for things, but I didn't find out how to do the captcha thing. I'm now trying previous suggestion.
    Someone else is currently helping me, I'll post the full code if I find out how.
     
    Last edited: Jul 15, 2011
  14. the known

    the known Power Member Premium Member

    Joined:
    Jan 31, 2011
    Messages:
    685
    Likes Received:
    419
    Occupation:
    Internet Marketing
    Location:
    The Netherlands
    Home Page:
    Got it working using this code:

    Code:
     Dim doc As IHTMLDocument2 = WebBrowser1.Document.DomDocument
                    Dim imgRange As IHTMLControlRange = CType(doc.body, HTMLBody).createControlRange
                    For Each img As IHTMLImgElement In doc.images
                        If img.GetAttribute("src").ToString.Contains("cimg?") Then
                            imgRange.add(img)
                            imgRange.execCommand("Copy", False, Nothing)
                            PictureBox1.Image = Clipboard.GetDataObject.GetData(DataFormats.Bitmap)
                            Exit For
                        End If
                    Next
     
    • Thanks Thanks x 2
  15. kill4

    kill4 Regular Member

    Joined:
    May 11, 2009
    Messages:
    243
    Likes Received:
    42
    Location:
    Texas
    Exactly what I needed to.

    OOPS Just noticed how old the thread is. My bad :eek: