QuestionGetting Captcha?

Posts 1–14 of 14 · Page 1 of 1
Getting Captcha?
I'm trying to grab a Captcha in the Webbrowser but it seems that the Captcha ID Changes every time, So is there another way to Grab the Image?
Nothing appears in the Picturebox1.

Code:
website: http://Website.net/captcha/captcha.php?t=dd586b17e0e1dbf851aaa86a8a154808
My Code:
Code:
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            For Each Captcha As HtmlElement In WebBrowser1.Document.Images
                On Error Resume Next
                If            Captcha.GetAttribute("src").Contains("http://Website.net/captcha/captcha.php?t=") Then
                    PictureBox1.Load(Captcha.GetAttribute("src"))
                End If
            Next
        End If
If the link ONLY contains the captcha you can use following code:

Picturebox1.Imagelocation = "http://Website.net/captcha/captcha.php?t=dd586b17e0e1dbf851aaa86a8a154808"

or just filter it, by searching all images
Quote Originally Posted by HWID View Post
If the link ONLY contains the captcha you can use following code:

Picturebox1.Imagelocation = "http://Website.net/captcha/captcha.php?t=dd586b17e0e1dbf851aaa86a8a154808"

or just filter it, by searching all images
Thanks! I've tried it even though it does grab a Captcha it's different every Refresh but it's not the Captcha on the Webbrowser.
Bump I still can't seem to get hold of the Current Captcha on the webbrowser.
Give this a shot, as this is what I use for my Youtube Converter program;

Try
Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Images
For Each htmlElement As HtmlElement In htmlElementCollection
Dim imgUrl As String = htmlElement.GetAttribute("src")
If imgUrl.Contains("default") Then
PictureBox1.ImageLocation = imgUrl
LinkLabel1.Text = PictureBox1.ImageLocation.ToString() 'testing purposes

End If
Next
Catch ex As Exception
End Try
End If

Change it around to suit your program, I copied it straight from my program! If you use HttpWebRequests then let me know.
Quote Originally Posted by Mrtm4n View Post
Give this a shot, as this is what I use for my Youtube Converter program;

Try
Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Images
For Each htmlElement As HtmlElement In htmlElementCollection
Dim imgUrl As String = htmlElement.GetAttribute("src")
If imgUrl.Contains("default") Then
PictureBox1.ImageLocation = imgUrl
LinkLabel1.Text = PictureBox1.ImageLocation.ToString() 'testing purposes

End If
Next
Catch ex As Exception
End Try
End If

Change it around to suit your program, I copied it straight from my program! If you use HttpWebRequests then let me know.

Thanks! I've just tried that but it Grabs nothing at all! Compared to the other code that grabs a Captcha but not the right one.... Thanks Anyway.
Quote Originally Posted by chicellwest View Post
Thanks! I've just tried that but it Grabs nothing at all! Compared to the other code that grabs a Captcha but not the right one.... Thanks Anyway.
Maybe the Captcha is dynamic and not readable as image file, sorry i dont know never worked with captchas. :/
Quote Originally Posted by chicellwest View Post
Thanks! I've just tried that but it Grabs nothing at all! Compared to the other code that grabs a Captcha but not the right one.... Thanks Anyway.
PM me the website link, and captcha. Ill do something for you!
Quote Originally Posted by Mrtm4n View Post
PM me the website link, and captcha. Ill do something for you!
Ok I have sent you a Message.
Have you logged the http requests and verified that the captcha isn't grabbed using a second request after the page is loaded?
I PMed you the results I ended up with, Ill also post them here


Code:
Imports System. IO (REMOVE SPACE)
Imports System.Net
Public Class Form1
    Function mpghImageDownloadMRTM4N(ByVal Url As String) As MemoryStream
        Dim byteBuff As Byte()
        Dim Request As HttpWebRequest = WebRequest.Create(Url)
        Dim Response As WebResponse = Request.GetResponse()
        Dim strm As Stream = Response.GetResponseStream()
        Dim binRead As BinaryReader = New BinaryReader(strm)
        byteBuff = binRead.ReadBytes(500000)
        Dim memStream As New MemoryStream(byteBuff)
        Response.Close()
        Return memStream
    End Function
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromStream(mpghImageDownloadMRTM4N("http://pokemoncreed.net/captcha/captcha.php?t="))
        'This can be placed in Form1_Load, Button_Click or anything you like!
    End Sub
End Class
Quote Originally Posted by Mrtm4n View Post
I PMed you the results I ended up with, Ill also post them here


Code:
Imports System. IO (REMOVE SPACE)
Imports System.Net
Public Class Form1
    Function mpghImageDownloadMRTM4N(ByVal Url As String) As MemoryStream
        Dim byteBuff As Byte()
        Dim Request As HttpWebRequest = WebRequest.Create(Url)
        Dim Response As WebResponse = Request.GetResponse()
        Dim strm As Stream = Response.GetResponseStream()
        Dim binRead As BinaryReader = New BinaryReader(strm)
        byteBuff = binRead.ReadBytes(500000)
        Dim memStream As New MemoryStream(byteBuff)
        Response.Close()
        Return memStream
    End Function
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromStream(mpghImageDownloadMRTM4N("http://pokemoncreed.net/captcha/captcha.php?t="))
        'This can be placed in Form1_Load, Button_Click or anything you like!
    End Sub
End Class
Ok I will say what happened so others maybe can help too, It does grab a Captcha but not the right one in Webbrowser1. :/
Thanks for trying to help anyway!
Quote Originally Posted by chicellwest View Post
Ok I will say what happened so others maybe can help too, It does grab a Captcha but not the right one in Webbrowser1. :/
Thanks for trying to help anyway!
What exactly do you mean by that? Do you mean than the CAPTCHA grabbed by the Web browser isn't the same one that the script gets? Because if that's the case it sounds like everything is working as intended since that's how CAPTCHA is designed to work.
The captcha is on every access a different one. That is why you have to download the image without any additional webcontrol.
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?