microsoft web browser component in c#.net

A

atul

hi
i m using microsoft web browser component in c#.net
i want that wen i open any url in that then the source of that url
come in my string

example: open any url say,yahoo.com in IE or firefox.
go in View--->source

i want that source to collect in any string or , etc,

i am using microsoft web browser for this how to retrieve that
source???
i want that wen i write any url in textbox of microsoft web browser ,
i get that source

any suggestions
Thanks'
Atul
 
A

Abdul Aleem

Atul, You can directly read the URL and open a response stream to read the
source/contents.
See if the following code helps, the 'result' string will contain the source
of your webpage.

ttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://www.google.com");

System.Net.WebProxy myProxy = new
System.Net.WebProxy("proxy1.emirates.net.ae", 8080);

myProxy.BypassProxyOnLocal = true;

request.Proxy = myProxy;

request.MaximumAutomaticRedirections = 4;

request.Timeout = 20000;

request.Credentials = CredentialCache.DefaultCredentials;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream receiveStream = response.GetResponseStream();

StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

string result = readStream.ReadToEnd();

response.Close();
 
G

Guest

webcontrol.DocumentText.ToString() will give you the actual html rendered
into webcontrol.

Happy coding,
 

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