Can web page contents be retrieved?

  • Thread starter Thread starter needin4mation
  • Start date Start date
N

needin4mation

Hi, I was trying to find the right set of objects to retrieve a web
page and display its contents. I don't want to display the page, just
the HTML. I used to use XMLHTTP Request, but I don't see a lot of
examples with .net and c#, so I thought it must have been replaced with
something else. Any help is appreciated. Thanks.
 
Hi needin4mation,

To retrieve information from an URL, simply use a WebClient or the more complext HttpWebRequest/HttpWebResponse.


WebClient client = new WebClient();
byte[] data = client.DownloadData("www.contoso.com");

string html = Encoding.Utf8.GetString(data);
 
Back
Top