get real html code from webbrowser
-
Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code: Document.write("Text"); i wanna get the code after the js runs. what i want is to get this: Text thanks, Marcus.
I'm not sure, however I would try this: - make sure your Internet Explorer has JavaScript enabled; - use a WebBrowser; - have it Navigate(string) to the URL you want; - use it's DocumentCompleted event to obtain its Document property. Caveat: complex pages may fire their DocumentCompleted event many times; what I typically do is compare the current WebBrowserDocumentCompletedEventArgs.URL with the original one, until they match. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I'm not sure, however I would try this: - make sure your Internet Explorer has JavaScript enabled; - use a WebBrowser; - have it Navigate(string) to the URL you want; - use it's DocumentCompleted event to obtain its Document property. Caveat: complex pages may fire their DocumentCompleted event many times; what I typically do is compare the current WebBrowserDocumentCompletedEventArgs.URL with the original one, until they match. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Thanks, but webbrowser1.DocumentText doesnt work, it gets: <html> <body> Document.write("Text"); </body> </html> =/ i dont know what to do anymore.
I'm not sure the "final HTML" actually exists at all; it could well be the browser interprets the incoming data and processes it on the fly, yielding data structures with displayable items that will eventually be shown. This[^] and other Google hits suggests there is a way, not necessarily an easy one. Start studying "DOM". :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I'm not sure the "final HTML" actually exists at all; it could well be the browser interprets the incoming data and processes it on the fly, yielding data structures with displayable items that will eventually be shown. This[^] and other Google hits suggests there is a way, not necessarily an easy one. Start studying "DOM". :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!! Marcus.
The thing to remember is that the final HTML may well be rendered out and extended using something like jQuery to append additional content.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!! Marcus.
There's no such thing as the "final HTML". Documents can be modified by any number of scripts and by any number of actions on the web page and at any time AFTER the document complete events fire. Click a button and a DIV might disappear. There's no way to tell. Your concept of a "final HTML" just doesn't exist, even more so today with more script, Flash, AJAX, HTML5, ... HTML is far from a static entity.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code: Document.write("Text"); i wanna get the code after the js runs. what i want is to get this: Text thanks, Marcus.
you can use C# screen scraping (WebClient class) so that you will get response sent by server as it is check this http://www.codersource.net/microsoft-net/c-advanced/html-screen-scraping-in-c.aspx[^]
============================================ The grass is always greener on the other side of the fence