Posted By

jprochazka on 11/30/12


Tagged


Versions (?)

Read an external url into a string variable.


 / Published in: VB.NET
 

Assigns the contents of a "url" to the string variable "result".

  1. string url = "http://www.translate-this.com/page.aspx";
  2. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  3. myRequest.Method = "GET";
  4. WebResponse myResponse = myRequest.GetResponse();
  5. StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
  6. string result = sr.ReadToEnd();
  7. sr.Close();
  8. myResponse.Close();

Report this snippet  

You need to login to post a comment.