Solved

C# and Internet Explorer Automation

Posted on 2013-05-29
4
1,278 Views
Last Modified: 2013-06-06
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.
0
Comment
Question by:rye004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 39207685
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.
0
 

Author Comment

by:rye004
ID: 39209326
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.
0
 

Accepted Solution

by:
rye004 earned 0 total points
ID: 39213645
So If figured out, there is not good way to do this.  What I need up doing is calling the following:

WebBrowser. ShowSaveAsDialog();

Once the dialog shows, I do the following:
            SendKeys.Send("%t{DOWN}{DOWN}~");
           
            SendKeys.Send("%s");

I realize this is lame, but it works.
0
 

Author Closing Comment

by:rye004
ID: 39224991
No better reason was given.
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question