使用WebBrowser 抓取运行js后html页面
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
private static void Delay(int Millisecond) { DateTime current = DateTime.Now; while (current.AddMilliseconds(Millisecond) > DateTime.Now) { System.Windows.Forms.Application.DoEvents(); } return; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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; } }
需要在页面顶部 page标签加入 AspCompat="true"