|
-
May 25th, 2009, 10:39 PM
#1
Thread Starter
Member
[RESOLVED] load captcha image to picturebox (captha has randomized name)
guys how can i get this captcha with randomized name, into my picture box ?!
HTML Code:
<div id="captchaDiv" class="ymemformfield" >
<input type="text" name="cword" id="cword" value="" size="10" maxlength="10" class="" tabindex="20" autocomplete="off">
<a id="captchaSwitchButton" ><input type="button" tabindex="21" id="caswitchurl" value="Need audio assistance?"></a>
<span class="small"><a href="" id="lnk_captcha_moreinfo" title="More info about verifying your account" target="pp">More infohttp://l.yimg.com/us.yimg.com/i/nt/ic/ut/alt1/hlp12_1.gif</a></span>
<p>This helps Yahoo! prevent automated registrations.</p>
<div id="captchaCanvas" >
<noscript>
<img src="https://ab.login.yahoo.com/img/iacu2OJZFel04sMMoRc33YK6ojMmTtxajmRALhfdJbKBwdLdLM4o6S3Zm6b1rvHH6cag8k7_r5NW93sCUl9PADBZculf4ceMF55I.jpg" width="290" height="80" alt="" border="2" id="cimg" class="cimg">
</noscript>
<a id="captchaRefreshAnchor"><input type="button" tabindex="22" id="captchaShuffleLink" value="Try a new code" ></a>
</div>
</div>
</div>
-
May 25th, 2009, 11:02 PM
#2
Frenzied Member
Re: load captcha image to picturebox (captha has randomized name)
Option Explicit should not be an Option!
-
May 26th, 2009, 02:42 AM
#3
Thread Starter
Member
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 ?
-
May 26th, 2009, 04:29 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|