Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTML Source after JavaScript manipulations

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.Net, i'd like to create an extra function of my custom webbrowsercontrol which receives the full HTML source.

Thanks in advance

like image 629
NicoJuicy Avatar asked Jan 25 '10 00:01

NicoJuicy


1 Answers

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.

like image 61
JohnFx Avatar answered Oct 05 '22 04:10

JohnFx