0

I am having some problem to get the exactly same HTML string as rendered by IE10. There're some slight difference between the one rendered by IE 10, and the one I retrieved with WebClient.DownloadString(url). (see this question)

How to get the exactly same HTML string? Do I need to simulate the Browser behavior?

Community
  • 1
  • 1
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
  • Browsers will automatically adjust some aspects of the source to make an object model that they can render. The only entirely reliable way would be some form of simulation/automation and then retrieval of the DOM from memory. – Matt Whipple Oct 11 '12 at 00:43
  • That essentially means I have to launch IE to browse the URL, right? – smwikipedia Oct 11 '12 at 00:50

2 Answers2

0

Try adding the user-agent header for IE10 to your request:

WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)");

Depending on your scenario (mobile, x64, etc.), the header might have different values. See IE10 User Agent String Update for other examples.

Brenda Bell
  • 1,139
  • 8
  • 10
0

This question is duplicated with this one: How to get the page source from an IE window?

And I have solved it there.

Community
  • 1
  • 1
smwikipedia
  • 61,609
  • 92
  • 309
  • 482