首页 > Web开发 > 详细

使用WebBrowser 抓取运行js后html页面

时间:2020-02-21 12:34:10      阅读:189      评论:0      收藏:0      [点我收藏+]
技术分享图片
private static void Delay(int Millisecond)
        {
            DateTime current = DateTime.Now;
            while (current.AddMilliseconds(Millisecond) > DateTime.Now)
            {

               System.Windows.Forms.Application.DoEvents();
            }
            return;
        }
View Code
技术分享图片
public string GetWebContent(string Url)
        {
            WebBrowser wb = new WebBrowser();
            wb.ScriptErrorsSuppressed = true;
            string xmlStr = string.Empty;
            wb.Navigate(Url);
            while (true)
            {
                Delay(2000);//延迟50毫秒
                if (wb.ReadyState == WebBrowserReadyState.Complete)//判断文档是否加载完毕
                {
                    if (!wb.IsBusy)
                    {
                        //在这里获取你想要的内容
                    }
                }
                continue;
            }
        }
View Code

需要在页面顶部 page标签加入   AspCompat="true"

使用WebBrowser 抓取运行js后html页面

原文:https://www.cnblogs.com/lxy6/p/12340403.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!