vietvoquoc
vietvoquoc

Reputation: 833

How can i get the final html from remote website?

I want to download the final html source from other website(after all javascript code run). For examlple i have a part jquery inside remote html file look like:

$(document).ready(function () {
   $('#dynamic').after('some dynamic content when page load');
});

And this is in my c# code:

var client = new WebClient();            
client.Encoding = System.Text.Encoding.UTF8;            
var content = client.DownloadString("http://myremotedomain.com/");

And also use WebRequest and WebResponse to do the same thing like above. And even use Webbrowser in window form from this link Use webbrowser control in asp.net

But i can not get the final html source , the result just raw html without affected by JavaScript.

Upvotes: 0

Views: 1766

Answers (1)

ryudice
ryudice

Reputation: 37456

You will need a headless browser that actually runs the javascript. Check this other post with a list of headless browsers with a C# API. Headless browser for C# (.NET)?

Upvotes: 1

Related Questions