Thread: C# основной форум/Load a DOM and Execute javascript, server side, with .Net

Load a DOM and Execute javascript, server side, with .Net

Load a DOM and Execute javascript, server side, with .Net






Re: Load a DOM and Execute javascript, server side, with .Net
C# - extract source code from webbrowser contro



Re: Load a DOM and Execute javascript, server side, with .Net
WebBrowser wb = new WebBrowser();
wb.Navigate(new uri(http://something);
HTMLDocument doc = wb.Document;
string body = doc.body;




Re: Load a DOM and Execute javascript, server side, with .Net
PhantomJS wrapper for .NET (C#)



Re: Load a DOM and Execute javascript, server side, with .Net

Scraping webpage generated by javascript with C#


Easier Method

It appears there is a nuget package for the phantomjs, such that you don't need the hub:

Install web driver:

Install-Package Selenium.WebDriver

Install embedded exe:

Install-Package phantomjs.exe

The code:

var driver = new PhantomJSDriver();

driver.Url = http://www.yoursite.co.uk/;

driver.Navigate();

//the driver can now provide you with what you need (it will execute the script)

//get the source of the page

var source = driver.PageSource;

//fully navigate the dom

var pathElement = driver.FindElementById("some-id");