2

I need to get the HTML of a website which is heavy on Javascript. When I try to do I get a receive code, but it is filled with Javascript.

Can I execute that JS after downloading and get the resulting HTML out of it?

Nathan
  • 11,938
  • 12
  • 55
  • 62
Daniel
  • 179
  • 2
  • 9
  • So you're trying to capture the response from an HTTP request to a website? And did you mean "exclude the JavaScript", rather than "execute"? – Tieson T. Sep 08 '11 at 07:07
  • The problem is, when I try to do the GET to aham...get..the website..it comes back with a lot of javascript code. I would like to execute that code, not exclude it. By executing it I would get the HTTP I want. – Daniel Sep 08 '11 at 07:08
  • Most JavaScript don't output HTML but are responsible for other things, such as AJAX, animations etc. – RvdK Sep 08 '11 at 07:08
  • I have used this tutorial here: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx – Daniel Sep 08 '11 at 07:09
  • JavaScript manipulates the HTML a **LOT** esp with frameworks such as jQuery - check out the first answer, it might work. – Aviad P. Sep 08 '11 at 07:10
  • 1
    @Daniel As @Al W alludes to below, you need something the evaluate the JavaScript, which normally means a web browser. The WinForms libraries contain a `WebBrowser` control you can use (which you can create purely in code, if memory serves me right) rather than sending it to an external browser application. – Tieson T. Sep 08 '11 at 07:14
  • Your question is unclear. What are you trying to do? Visually render the web page in your application? Get a copy of the HTML (not HTTP) and manipulate it? Please clarify. – Serge Wautier Sep 08 '11 at 07:23

1 Answers1

2

The most straight forward way to do this would be to embed a WebBrowser control into a windows form and then use the DOM

C# WebBrowser control -- Get Document Elements After AJAX?

Community
  • 1
  • 1
Al W
  • 7,539
  • 1
  • 19
  • 40