开发者

Get HTML Source after JavaScript manipulations

开发者 https://www.devze.com 2022-12-18 04:20 出处:网络
How do i get the full! HTML source of a web page, after it has run some JavaScript code which has made manipulations to the HTML source.

How do i get the full! HTML source of a web page, after it has run some JavaScript code which has made manipulations to the HTML source.

I'm using the WebbrowserControl of VB.开发者_JAVA百科Net, i'd like to create an extra function of my custom webbrowsercontrol which receives the full HTML source.

Thanks in advance


The trick is going to be finding a way to notify the control about whether the JS is done running. You might be able to do that by having the JS set a form element' value (isJSComplete) when it has completed and polling with the web browser control.

Use the following code to check a form value to see if it is ready

MyBrowserControl.document.getElementById('isJSComplete');

Use the following code to pull the HTML from the page.

MyBrowserControl.Document.documentElement.OuterHTML

Better yet, here is an article showing how to wire up JS events to be handled by the WebBrowser control. You could just fire an event when the JS is done and have your code trap that event and then pull the HTML using the above approach.

0

精彩评论

暂无评论...
验证码 换一张
取 消