Use WebRequest and WebResponse to read a web page : WebRequest « Network « C# / CSharp Tutorial






using System;
using System.Net;
using System.IO;

public class MainClass {

   [STAThread]
   public static void Main(string[] args)
   {
       string htmlUri = "http://www.java2s.com";
       WebRequest requestHtml = WebRequest.Create(htmlUri);       
       WebResponse responseHtml = requestHtml.GetResponse();
       // Read the text from the response stream.
       using (StreamReader r = new StreamReader(responseHtml.GetResponseStream()))
       {
           Console.WriteLine( r.ReadToEnd());
       }

   }
 
}


     Java examples (example source code) Organized by topic 
...
...








33.20.WebRequest
33.20.1.Use WebRequest
33.20.2.Use WebRequest and WebResponse to read a web page
33.20.3.Download image from a website
33.20.4.Use WebRequest to create a StreamReader
33.20.5.Save what you read from WebRequest to a file
33.20.6.Reading Web Page As HTML
33.20.7.Use WebRequest to read csv file from finance.yahoo.com