Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get real html code from webbrowser

get real html code from webbrowser

Scheduled Pinned Locked Moved C#
questionjavascripthtml
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mabrahao
    wrote on last edited by
    #1

    Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code: Document.write("Text"); i wanna get the code after the js runs. what i want is to get this: Text thanks, Marcus.

    L N 2 Replies Last reply
    0
    • M mabrahao

      Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code: Document.write("Text"); i wanna get the code after the js runs. what i want is to get this: Text thanks, Marcus.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I'm not sure, however I would try this: - make sure your Internet Explorer has JavaScript enabled; - use a WebBrowser; - have it Navigate(string) to the URL you want; - use it's DocumentCompleted event to obtain its Document property. Caveat: complex pages may fire their DocumentCompleted event many times; what I typically do is compare the current WebBrowserDocumentCompletedEventArgs.URL with the original one, until they match. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      M 1 Reply Last reply
      0
      • L Luc Pattyn

        I'm not sure, however I would try this: - make sure your Internet Explorer has JavaScript enabled; - use a WebBrowser; - have it Navigate(string) to the URL you want; - use it's DocumentCompleted event to obtain its Document property. Caveat: complex pages may fire their DocumentCompleted event many times; what I typically do is compare the current WebBrowserDocumentCompletedEventArgs.URL with the original one, until they match. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        M Offline
        M Offline
        mabrahao
        wrote on last edited by
        #3

        Thanks, but webbrowser1.DocumentText doesnt work, it gets: <html> <body> Document.write("Text"); </body> </html> =/ i dont know what to do anymore.

        L 1 Reply Last reply
        0
        • M mabrahao

          Thanks, but webbrowser1.DocumentText doesnt work, it gets: <html> <body> Document.write("Text"); </body> </html> =/ i dont know what to do anymore.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          I'm not sure the "final HTML" actually exists at all; it could well be the browser interprets the incoming data and processes it on the fly, yielding data structures with displayable items that will eventually be shown. This[^] and other Google hits suggests there is a way, not necessarily an easy one. Start studying "DOM". :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          M 1 Reply Last reply
          0
          • L Luc Pattyn

            I'm not sure the "final HTML" actually exists at all; it could well be the browser interprets the incoming data and processes it on the fly, yielding data structures with displayable items that will eventually be shown. This[^] and other Google hits suggests there is a way, not necessarily an easy one. Start studying "DOM". :)

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            M Offline
            M Offline
            mabrahao
            wrote on last edited by
            #5

            I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!! Marcus.

            P D 2 Replies Last reply
            0
            • M mabrahao

              I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!! Marcus.

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              The thing to remember is that the final HTML may well be rendered out and extended using something like jQuery to append additional content.

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

              1 Reply Last reply
              0
              • M mabrahao

                I think it exists, firebug shows the final HTML, but ok... i will look for DOM. Thanks anyway!! Marcus.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                There's no such thing as the "final HTML". Documents can be modified by any number of scripts and by any number of actions on the web page and at any time AFTER the document complete events fire. Click a button and a DIV might disappear. There's no way to tell. Your concept of a "final HTML" just doesn't exist, even more so today with more script, Flash, AJAX, HTML5, ... HTML is far from a static entity.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                1 Reply Last reply
                0
                • M mabrahao

                  Hi, how can i get the real html code in a webbrowser object??? a mean, if the page has the following code: Document.write("Text"); i wanna get the code after the js runs. what i want is to get this: Text thanks, Marcus.

                  N Offline
                  N Offline
                  Nitin S
                  wrote on last edited by
                  #8

                  you can use C# screen scraping (WebClient class) so that you will get response sent by server as it is check this http://www.codersource.net/microsoft-net/c-advanced/html-screen-scraping-in-c.aspx[^]

                  ============================================ The grass is always greener on the other side of the fence

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups