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 wepage source code

Get wepage source code

Scheduled Pinned Locked Moved C#
7 Posts 3 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.
  • A Offline
    A Offline
    Amauw Scritz
    wrote on last edited by
    #1

    Hi ! I use the object create my own web browser. private AxSHDocVw.AxWebBrowser instVisualObjectCreator; then by using instVisualObjectCreator.Navigate(); I show it inside my client form. But can i use this facility (instVisualObjectCreator object) to get the source of the web page. Is there a method to get the source code from this object. I've gone through the documentation but somehow the solution has illuded me. Thanx in Advance

    S 1 Reply Last reply
    0
    • A Amauw Scritz

      Hi ! I use the object create my own web browser. private AxSHDocVw.AxWebBrowser instVisualObjectCreator; then by using instVisualObjectCreator.Navigate(); I show it inside my client form. But can i use this facility (instVisualObjectCreator object) to get the source of the web page. Is there a method to get the source code from this object. I've gone through the documentation but somehow the solution has illuded me. Thanx in Advance

      S Offline
      S Offline
      Stephane Rodriguez
      wrote on last edited by
      #2

      using System.Runtime.InteropServices; IHTMLDocument2 doc = (IHTMLDocument2) instVisualObjectCreator.Document; UCOMIPersistFile pf = (UCOMIPersistFile) doc; pf.Save(@"c:\myhtmlpage.html",true); PS : the IHTMLDocument2 interface is from the mshtml primary interop library (which you can add to your project, c:\program files\microsoft.NET\primary interop assemblies\microsoft.mshtml.dll).

      D 1 Reply Last reply
      0
      • S Stephane Rodriguez

        using System.Runtime.InteropServices; IHTMLDocument2 doc = (IHTMLDocument2) instVisualObjectCreator.Document; UCOMIPersistFile pf = (UCOMIPersistFile) doc; pf.Save(@"c:\myhtmlpage.html",true); PS : the IHTMLDocument2 interface is from the mshtml primary interop library (which you can add to your project, c:\program files\microsoft.NET\primary interop assemblies\microsoft.mshtml.dll).

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #3

        Or he could do it the "Completely managed" way:

        using System;
        using System.Net;
        using System.Text;
        
        namespace Utilities
        {
            class WebPage
            {
                static string GetHtml(string address)
                {
                    WebClient client = new WebClient();
                    return Encoding.Default.GetString(client.DownloadData(address));
                }
            }
        }
        

        Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing

        S 1 Reply Last reply
        0
        • D David Stone

          Or he could do it the "Completely managed" way:

          using System;
          using System.Net;
          using System.Text;
          
          namespace Utilities
          {
              class WebPage
              {
                  static string GetHtml(string address)
                  {
                      WebClient client = new WebClient();
                      return Encoding.Default.GetString(client.DownloadData(address));
                  }
              }
          }
          

          Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing

          S Offline
          S Offline
          Stephane Rodriguez
          wrote on last edited by
          #4

          Geeee! This is ok for a completely IE-less scenario.

          D 1 Reply Last reply
          0
          • S Stephane Rodriguez

            Geeee! This is ok for a completely IE-less scenario.

            D Offline
            D Offline
            David Stone
            wrote on last edited by
            #5

            Yeah. That was my point. Why on earth would you need to use IE?:confused:


            Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing

            S 1 Reply Last reply
            0
            • D David Stone

              Yeah. That was my point. Why on earth would you need to use IE?:confused:


              Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing

              S Offline
              S Offline
              Stephane Rodriguez
              wrote on last edited by
              #6

              Well, I guess that saving the html source code from the current web page is the final scenario step for Windows apps that embed IE because they want to show the web page(s). The .NET WebClient helper class is no substitution for showing pages.

              D 1 Reply Last reply
              0
              • S Stephane Rodriguez

                Well, I guess that saving the html source code from the current web page is the final scenario step for Windows apps that embed IE because they want to show the web page(s). The .NET WebClient helper class is no substitution for showing pages.

                D Offline
                D Offline
                David Stone
                wrote on last edited by
                #7

                Ah...I see now. I didn't think of it in terms of actually showing pages...just downloading them and parsing their source (which I've done a lot of recently).


                Hawaian shirts and shorts work too in Summer. People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage... -Anna-Jayne Metcalfe on Paintballing

                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