How to get source displayed by axshdocvw.dll as string

K

Ken Arway

Using VS2003, .NET1.1 and C# windows form app, I'm successfully displaying
web pages using the axshdocvw.dll. Now I want to capture the source
displayed in the window as a text string. Any ideas? I can't find any
properties or methods that will do this...

Thanks,
Ken
 
K

kalpesh

If I am correctly interpreting this, you want to get the source behind
the loaded page, right ?

If yes, import the HTML Object library (mshtml.dll). Load the page
into browser using webbrowser1.navigate2, catch an event that will
tell the state that the page is loaded completely

And then

Dim doc As HTMLDocument
Set doc = WebBrowser1.Document

msgbox(doc.childNodes(0).innerHTML)

HTH
Kalpesh
 
K

Ken Arway

Thanks for the response. I've found an earlier post from Justin Rogers
which also solves the problem:
string contents = null;
string url = "http://www.microsoft.com";
HttpWebRequest wreq = (HttpWebRequest) WebRequest.Create(url);
using(HttpWebResponse wresp = (HttpWebResponse) wreq.GetResponse()) {
using(StreamReader sr = new StreamReader(wresp.GetResponseStream())) {
contents = sr.ReadToEnd();
sr.Close();
}
wresp.Close();
}

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top