How do I get a web page's HTML source from a page open in my browser? RRS feed

  • Question

  • I am trying to get the HTML source of a web page using the WebClient DownloadString method, however this only returns the page's initial source. When the page is open in my browser, some of the elements change in the HTML and I need the updated source. Is there a way to do this?
    • Moved by Kristin Xie Wednesday, December 17, 2014 1:30 AM
    Monday, December 1, 2014 8:55 PM


All replies

  • What's wrong with the F12-Key the Devlopment tool that browers like IE, FF and Chrome have to look at a page's HTML source?
    Monday, December 1, 2014 9:06 PM
  • I need my program to display information based on what parts the page's HTML contains as I perform actions in the browser that changes things.
    Monday, December 1, 2014 9:13 PM
  • Well you still need to see the HTML for that page after it has been rendered, and that's what the browser develment tool does for you. You need to find out what is rendered so you can address it.
    Monday, December 1, 2014 9:20 PM
  • I don't understand... You're saying I need to tell my program to press F12 and look at the HTML that the dev tool shows?
    Monday, December 1, 2014 9:23 PM
  • How are you going to find something on the page to look for if you don't inspect the page in the browser while the page is being displayed to you and pressing the F12 key to see the HTML that was rendered?

    You need to be addressing the HTML Document using Javascript to address HTML elements on the rendered page. You can use Jquery too.  

    Monday, December 1, 2014 9:36 PM
  • I already know what I'm looking for, I know what HTML tags the information I'm looking for is in, and I have code that can find it. I just need to get the version of the webpage that the user is looking at through code so the code I have can search through it.
    Monday, December 1, 2014 9:42 PM
  • Post to the fourm they can help you there.


    • Marked as answer by Just Karl Tuesday, December 23, 2014 10:11 PM
    Monday, December 1, 2014 10:05 PM
  • Very simple:

    using System.Net;
    using (WebClient client = new WebClient ()) 
        string htmlCode = client.DownloadString("http://THE ADDRESS");
        // Now you have the HTML as a string


    Noam B.

    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...

    • Proposed as answer by Noam B Tuesday, December 2, 2014 11:17 AM
    Tuesday, December 2, 2014 11:16 AM