c# 利用 webbrowser 解析 html

using(var wb = new WebBrowser())
        {
            wb.ScriptErrorsSuppressed = true;
            wb.Navigate("about:blank");
            var startTime = DateTime.Now;
            while (true)
            {
                Application.DoEvents();
                if (wb.ReadyState == WebBrowserReadyState.Loaded
                    || wb.ReadyState == WebBrowserReadyState.Complete
                    || startTime.AddMilliseconds(1) < DateTime.Now)
                    break;
            }
            wb.Document.Body.InnerHtml = "<h1>Hello</h1>";
            var x = wb.Document.Body.Children[0].OuterHtml ;
        }

 

posted on 2023-01-07 09:15  空明流光  阅读(254)  评论(0编辑  收藏  举报

导航