Link to home
Start Free TrialLog in
Avatar of rye004
rye004Flag for United States of America

asked on

C# and Internet Explorer Automation

I have a web page that I am loading into Internet Explorer.  I am then trying to do a “Save As” to HTML via Automation.  I have been searching for a couple days and I can’t figure out how to do this.

I have been trying to do this with Microsoft.mshtml and SHDocVw in Visual Studio.
Any direction would be greatly appreciated.
Avatar of Kalpesh Chhatrala
Kalpesh Chhatrala
Flag of India image

you can try WebClient.

WebClient MyClient = new WebClient();
Byte[] MypageData = MyClient.DownloadData("http://kalpesh.biz");
string cDoc = Encoding.ASCII.GetString(MypageData);

Open in new window


or

you can try browser automation like below
 
webBrowser1.Navigate("https://www.google.com/");

            while (true)
            {
                if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
                {
                    break;
                }
                Application.DoEvents();
            }
            String cDoc = webBrowser1.Document.Body.InnerHtml;

Open in new window



you can save cDoc in html File.
Avatar of rye004

ASKER

Thank you kalpesh2804 for your response.
I did originally try “webBrowser1.Document.Body.InnerHtml”.
However it only gets the HTML from when the page was loaded.
With the “Save As” in IE it does a conversion process to save the HTML – which is what I am looking for.  If you take a website like “yahoo.com”, more content is added the more you scroll down.  If you do “InnerHtml”, it only gets the HTML that was loaded with the page.  However if you do a “Save As”, it does a conversion to view it later.
Hopefully this make sense.
ASKER CERTIFIED SOLUTION
Avatar of rye004
rye004
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rye004

ASKER

No better reason was given.