Results 1 to 4 of 4

Thread: [RESOLVED] load captcha image to picturebox (captha has randomized name)

Hybrid View

  1. #1
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: load captcha image to picturebox (captha has randomized name)

    Option Explicit should not be an Option!

  2. #2

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    36

    Re: load captcha image to picturebox (captha has randomized name)

    dont work that page has over than 4 image it load spacer image ,
    any one know better way ?

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: load captcha image to picturebox (captha has randomized name)

    You can use this function to extract the URL of the captcha image (assuming it's the .jpg one?)

    Code:
    Private Function CaptchaURL(ByRef HTML As String) As String
        '<div id="captchaCanvas" >
        '<noscript>
        
        Dim lonStart As Long, strStart As String
        Dim lonLenStart As Long, lonEnd As Long
        
        strStart = "<div id=""captchaCanvas"" >"
        lonLenStart = Len(strStart)
        
        lonStart = InStr(1, HTML, strStart)
        
        If lonStart > 0 Then
            strStart = "<noscript>"
            lonStart = InStr(lonStart + 1, HTML, strStart)
            
            If lonStart > 0 Then
                lonStart = InStr(lonStart + 1, HTML, "<img src=""")
                
                If lonStart > 0 Then
                    lonStart = lonStart + 10 'Length of: <img src="
                    lonEnd = InStr(lonStart, HTML, Chr$(34))
                    
                    If lonEnd > 0 Then
                        CaptchaURL = Mid$(HTML, lonStart, lonEnd - lonStart)
                    End If
                
                End If
            
            End If
        
        End If
        
    End Function
    Just pass it the HTML code and it will extract it. Then you can use URLDownloadToFile() API function (do a search for it) to download the image. Then load it into a PictureBox using PictureBox.Picture = LoadPicture("C:\Path\to\saved\image.jpg")

    It would have been really helpful if you at least posted the complete HTML or the URL to the page that has the captcha image...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width