如何用webbrowser获取ajax动态生成的网页的源码?

1.步骤一:修改IE内核的版本(这个方法厉害了)

public Form1()

{
InitializeComponent();
int BrowserVer, RegVal;

// get the installed IE version
using (WebBrowser Wb = new WebBrowser())
BrowserVer = Wb.Version.Major;

// set the appropriate IE version
if (BrowserVer >= 11)
RegVal = 11001;
else if (BrowserVer == 10)
RegVal = 10001;
else if (BrowserVer == 9)
RegVal = 9999;
else if (BrowserVer == 8)
RegVal = 8888;
else
RegVal = 7000;

// set the actual key
RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);
Key.Close();
}

2.步骤  应用dynamic处理com对象利用scrollintoview方法模拟拉动滚动条。

 

参考资料:http://stackoverflow.com/questions/17922308/use-latest-version-of-internet-explorer-in-the-webbrowser-control

posted @ 2017-02-06 10:56  公众号python学习开发  阅读(460)  评论(0编辑  收藏  举报