views:

68

answers:

2

Possible Duplicate:
How can I download HTML source in C#

I want the source HTML of the webpage so I can parse it in my C# program.

+2  A: 

System.Net.WebClient

Josh Einstein
+1  A: 

Hi,

You can use the .net HttpWebRequest and HttpWebResponse to do this. See the example code below.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("url");
request.Timeout = 5000;

using (WebResponse response = (HttpWebResponse)request.GetResponse())
{
    Stream responeStream = response.GetResponseStream();

    //do something with the response stream
}

Enjoy!

Doug