15 July, 2011

Get Captcha Image in PictureBox [VB.NET]

There is the source to get a ReCaptcha Image into your PictureBox. This only works for ReCaptcha so far. Will be making more soon.
Theres 2 Methods:
1) Put this Sub in your Project.
You need:
  • PictureBox --> name = PictureBox1
  • WebBrowser --> name = WebBrowser1

getcaptcha()
Code:
Public Sub getcaptcha()
  Dim str As String = WebBrowser1.Document.GetElementById("recaptcha_image").InnerHtml 'Gets the html code for the recaptcha_image element
  Dim img As String = str.Remove(0, 33).Replace(""" width=300 height=57>", "") 'Deletes all the info around the link because the height and width will never change
  PictureBox1.ImageLocation = img 'Sets the ImageLocation to the URL of the ReCaptcha Image
    End Sub

Then find the WebBrowser1 Document Completed Sub (shown below)
Code:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

  End Sub

And Add this code below to the Sub Above ^^
Code:
If WebBrowser1.DocumentTitle.Contains("Emk") Then
    getcaptcha() 'Runs the sub getcaptcha()
  End If

So it would look like this
Code:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    getcaptcha() 'Runs the sub getcaptcha()

  End Sub

Here is the whole source of the program if you don't want to download...

2) Download my Source code. It says Get Youtube Captcha but it really doesn't so just a heads up. Download link is http://dl.dropbox.com/u/11786922/Get%20Y...aptcha.zip

Screenshot

This isn't an auto Captcha all it does it get the image from the website and put it in a PictureBox.

Labels:

2 Comments:

At September 5, 2011 at 2:48 PM , Blogger Unknown said...

if any body want some information about Captcha Code i will refer him this blog..
Good work...

 
At February 28, 2014 at 5:37 AM , Blogger Unknown said...

hi
can i get help
how can show captcha in PictureBox
code
[code]
<img src="/alpha/captcha.php?1393542946" width="150" height="25" title="Click for another image" alt="CAPTCHA" id="asc"[/code]

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home