C#点击打开webbrowser中网页中的超链接

1:使用webbrowser的 links方法

            //if (webBrowser1.Document != null)
            //{
            //    int j = webBrowser1.Document.Links.Count;
            //    for (int i = 0; i < j ; i++)
            //    {
            //        webBrowser1.Document.Links[i].InvokeMember("Click");
            //    }
            //}

2: 使用了 HtmlDocument 的方法

      HtmlDocument doc = this.webBrowser1.Document;

            for (int i = 0; i < doc.All.Count; i++)
            {
                if (doc.All[i].TagName == "A" || doc.All[i].TagName == "a")
                {
                    HtmlElement elem = doc.All[i];
                    if (elem.OuterText == "自动收录网站")
                    {
                        elem.InvokeMember("Click");
                    }
                }
            }

还有一种方法自己测试了一半就没做了.因为时间很紧,写下来只要做以后的参考.          

原文地址:https://www.cnblogs.com/yeye518/p/2231642.html