zoukankan      html  css  js  c++  java
  • 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");
                        }
                    }
                }

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

  • 相关阅读:
    线程同步-使用CountDownEvent类
    WPF 依赖属性和附加属性
    ef core
    Razor语法
    python-爬虫
    ftp
    泛型
    结对编程作业
    第三次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/yeye518/p/2231642.html
Copyright © 2011-2022 走看看