要获取其它网站页面中的数据,比如文本框的验证码之类
首先在代码中添加Microsoft.mshtml.dll引用,该引用地址是在C:\Program Files\Microsoft.NET\Primary Interop Assemblies,
再在页面中添加一个webBrowse控件,用于获取网站页面。
using mshtml;
this.webBrowser1.Url = new Uri(http://www.);
public static string GetCodeName(WebBrowser wbMail)
{
HtmlDocument doc1 = wbMail.Document;
// checkCode 为需要获取网站页面中文本框的ID
HtmlElement element = doc1.GetElementById("checkCode");
string value = element.GetAttribute("value");
return value;
}
浙公网安备 33010602011771号