Read an external url into a string variable.


/ Published in: VB.NET
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.