You need to extract the html from the current web page in IE. This article details how to do that.

  1. Create a console application in any version of Visual Studio using .Net version 1|2|3|3.5.
  2. Add two Com object references which will allow us to manipulate IE.

    image

  3. Note the code sample below does not require the using directive for the objects, so just add the code as is.
  4. Then find the instances of IE and extract the document:
SHDocVw.ShellWindows shellWindows
    = new SHDocVw.ShellWindowsClass();
 
string filename;
 
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
    filename
        = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
 
    if (filename.Equals("iexplore"))
    {
        Console.WriteLine("Web Site   : {0}", ie.LocationURL);
 
        mshtml.IHTMLDocument2 htmlDoc 
             = ie.Document as mshtml.IHTMLDocument2;
 
        Console.WriteLine("   Document Snippet: {0}", 
             ( ( htmlDoc != null ) ? htmlDoc.body.outerHTML.Substring(0, 40) 
                                   : "***Failed***" ));
        Console.WriteLine("{0}{0}", Environment.NewLine);
    }
}

Here is a screen-shot of the output:

image

Share