How open internet explorer window or tab, navigate it and get her document(HTMLDocument or InternetExplorer) using c# and mshtml library. The type of IE object should be HTMLDocument or InternetExplorer.
Asked
Active
Viewed 5,688 times
2
-
What have you tried? Stack Overflow is not a place for "just give me the code"-style questions. – ThiefMaster Oct 18 '12 at 12:22
-
Do you need IE? Otherwise download the document direct, as described here http://stackoverflow.com/questions/599275/how-can-i-download-html-source-in-c-sharp – Paul Grimshaw Oct 18 '12 at 12:22
-
I don't want get her document file. I want get her object(InternetExplorer or mshtml.HTMLDocument) – Yengibar Oct 18 '12 at 12:27
2 Answers
7
If you want an interactive-automated instance of IE add a (COM) reference to Microsoft Internet Controls;
private void Form1_Load(object sender, EventArgs e) {
var IE = new SHDocVw.InternetExplorer();
IE.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(OnNavigateComplete2);
object URL = "http://www.stackoverflow.com";
IE.Visible = true;
IE.Navigate2(ref URL);
}
public void OnNavigateComplete2(object pDisp, ref object url) {
var IE = (SHDocVw.InternetExplorer)pDisp;
MessageBox.Show(IE.Document.Title);
}

Alex K.
- 171,639
- 30
- 264
- 288
-1
InternetExplorer ie= new InternetExplorer();
ie.Navigate("www.example.com");
ie.Visible = true;
Thread.Sleep(5000);//wait until page loads
mshtml.HTMLDocument doc;
doc = ie.Document;

Gokul
- 788
- 2
- 12
- 30