C#验证码本地获取范例

验证码放在了js里面,所以我们直接读取到剪切板然后放回到picturebox1中

测试效果图:

C#验证码本地获取范例_第1张图片

            webBrowser1.Navigate("http://reg.renren.com/"); 
            while (webBrowser1.ReadyState < WebBrowserReadyState.Complete) Application.DoEvents(); 
            HTMLDocument html = (HTMLDocument)this.webBrowser1.Document.DomDocument; 
            IHTMLControlElement img = (IHTMLControlElement)webBrowser1.Document.Images["verifyPic"].DomElement;   
            IHTMLControlRange range = (IHTMLControlRange)((HTMLBody)html.body).createControlRange();   
            range.add(img);   
            range.execCommand("Copy", false, null);   
            img = null;   
            range = null;   
            html = null;   
            if (Clipboard.ContainsImage())   
        {   
            this.pictureBox1.Image = Clipboard.GetImage();   
        }   
            else  
        {   
            MessageBox.Show("获取失败!");   
        }   
            Clipboard.Clear(); 

你可能感兴趣的:(C#验证码本地获取范例)