Reputation: 14243
I know that I can get source of web page with this code:
browser.DocumentText;
some data of page filled by javascript innetHtml
function and will not visible in browser.Text
but in browser
's output is visible.
How can I get source code of data that added by javascript to page?
Upvotes: 1
Views: 2326
Reputation: 3041
If you know what type of tag contains the inner HTML you want to get at, you could do something like this (this example loops through the div tags, but you could do p, or table cells, or whatever):
HtmlElementCollection collection = browser.Document.GetElementsByTagName("div");
foreach (HtmlElement element in collection) {
string html = element.InnerHtml;
string text = element.InnerText;
// do something with the HTML or text here...
}
Or if you know the specific ID of the element you want to get, use:
HtmlElement element = browser.Document.GetElementById("someId123");
if(null != element) // do something with it...
Upvotes: 2
Reputation: 1393
You could give HtmlAgilityPack a try and follow this answer.
HtmlWeb webGet = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = webGet.Load(url);
Upvotes: 1