Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download js generated html with C#

There is a reports website which content I want to parse in C#. I tried downloading the html with WebClient but then I don't get the complete source since most of it is generated via js when I visit the website.

I tried using WebBrowser but could't get it to work in a console app, even after using Application.Run() and SetApartmentState(ApartmentState.STA).

Is there another way to access this generated html? I also took a look into mshtml but couldn't figure it out.

Thanks

like image 632
lander16 Avatar asked Jan 23 '12 22:01

lander16


2 Answers

The Javascript is executed by the browser. If your console app gets the JS, then it is working as expected, and what you really need is for your console app to execute the JS code that was downloaded.

like image 167
John3136 Avatar answered Nov 12 '22 17:11

John3136


You can use a headless browser - XBrowser may server.

If not, try HtmlUnit as described in this blog post.

like image 45
Oded Avatar answered Nov 12 '22 18:11

Oded