用webBrowser模拟点击页面
自动输入内容并提交
this.tb_url.Text = "http://www.baidu.com"; this.webBrowser1.Url = new Uri(this.tb_url.Text.Trim()); HtmlElement kw = webBrowser1.Document.All["kw"]; HtmlElement su = webBrowser1.Document.All["su"]; string str = DateTime.Now.ToString(); str = "百度知道"; kw.SetAttribute("value", str); su.InvokeMember("click");
模拟点击页面中的链接
HtmlElementCollection link = webBrowser1.Document.GetElementsByTagName("a"); for (int i = 0; i < link.Count; i++) { if (link[i].InnerHtml != null) { if (link[i].InnerHtml.IndexOf("百度") != -1) //带百度2个字的链接会被点击 { link[i].InvokeMember("click"); break; } } }
量的积累到质的飞越