Is there anyway to copy CAPTCHA image from website from webwiev and then paste it in imagewiev? I used to work in VB.NET so I'm trying something new. This is the code form vb :
无论如何从webwiev复制网站上的CAPTCHA图像,然后将其粘贴到imagewiev中?我曾经在VB.NET工作,所以我正在尝试新的东西。这是代码形式vb:
Private Sub captcha()
Dim doc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
Dim imgrange As mshtml.IHTMLControlRange = CType(doc.body, mshtml.HTMLBody).createControlRange
For Each img As mshtml.IHTMLImgElement In doc.images
If img.getattribute("src").ToString.Contains("jkjkhjkhjk") Then
imgrange.add(img)
imgrange.execCommand("copy", False, Nothing)
PictureBox1.Image = Clipboard.GetDataObject.GetData(DataFormats.Bitmap)
Exit For
End If
Next
End Sub
1 个解决方案
#1
0
No way to paste in imageView, just you load the web view. like that,
无法粘贴到imageView中,只需加载Web视图即可。像那样,
[self.captchaWebView loadHTMLString:@"<html><head><style type='text/css'>a {color:white;font-size:20px;font-style:bold}small{color:white;font-size:20px;font-style:bold}</style><script type='text/javascript'>var a = 49; b= 65; var c =100; var d = 70;var f=85;function DrawCaptcha(){if(a==57){a=49;}var main = document.getElementById('captchaText'); var a1=String.fromCharCode(a);var b1=String.fromCharCode(b);var c1=String.fromCharCode(c);var d1=String.fromCharCode(d);var f1=String.fromCharCode(f);main.innerHTML = a1+b1+c1+d1+f1;a=a+1;b=b+1;c=c+1;d=d+1;f=f+1;}function ValidCaptcha(){var str1=document.getElementById('captchaText').innerHTML;var str2=document.getElementById('txtinput').value;if(str1==str2)return true;return false;}</script></head><body bgcolor = 'rgb(231,184,17)'><lable style='font-size:28px;'><font color='white' face = 'helevetica Bold'><b> Enter Captcha</b></font></label><br/> <span id='captchaText' style='font-size:25pt;font-family:Chalkduster'>5Klne</span><br/><br/><input type='text' style=border:none;font-size:20px;height:40px' id='txtinput' /><br/><br/> <small>Can't read this? </small><a href='#' onclick='DrawCaptcha()'>try another</a></body></html>" baseURL:nil];
#1
0
No way to paste in imageView, just you load the web view. like that,
无法粘贴到imageView中,只需加载Web视图即可。像那样,
[self.captchaWebView loadHTMLString:@"<html><head><style type='text/css'>a {color:white;font-size:20px;font-style:bold}small{color:white;font-size:20px;font-style:bold}</style><script type='text/javascript'>var a = 49; b= 65; var c =100; var d = 70;var f=85;function DrawCaptcha(){if(a==57){a=49;}var main = document.getElementById('captchaText'); var a1=String.fromCharCode(a);var b1=String.fromCharCode(b);var c1=String.fromCharCode(c);var d1=String.fromCharCode(d);var f1=String.fromCharCode(f);main.innerHTML = a1+b1+c1+d1+f1;a=a+1;b=b+1;c=c+1;d=d+1;f=f+1;}function ValidCaptcha(){var str1=document.getElementById('captchaText').innerHTML;var str2=document.getElementById('txtinput').value;if(str1==str2)return true;return false;}</script></head><body bgcolor = 'rgb(231,184,17)'><lable style='font-size:28px;'><font color='white' face = 'helevetica Bold'><b> Enter Captcha</b></font></label><br/> <span id='captchaText' style='font-size:25pt;font-family:Chalkduster'>5Klne</span><br/><br/><input type='text' style=border:none;font-size:20px;height:40px' id='txtinput' /><br/><br/> <small>Can't read this? </small><a href='#' onclick='DrawCaptcha()'>try another</a></body></html>" baseURL:nil];