|
#region 獲取難證碼圖片 /// <summary> /// 獲取難證碼圖片 /// </summary> public void requestVerify() { try { HTMLDocument html = (HTMLDocument)this.webLogin.Document.DomDocument; IHTMLControlElement img = (IHTMLControlElement)webLogin.Document.Images["verifyImg"].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.picVerify.Image = null; this.picVerify.Image = Clipboard.GetImage(); } Clipboard.Clear(); } catch (Exception e) { throw (new Exception(e.Message + e.StackTrace + e.Source)); return; } } #endregion IHTMLControlElement img = (IHTMLControlElement)webLogin.Document.Images["verifyImg"].DomElement; 至于這里找到那個驗證碼圖片的方式很多,可以根所圖片ID,NAME,SRC,TITLE等等... 需引用一個dll ,Microsoft.mshtml
|