Posted By

jprochazka on 12/15/12


Tagged


Versions (?)

Get Entire Markup For The Supplied URL.


 / Published in: C#
 

Returns the entire markup making up the specified webpage.

  1. public string getHtml(string url)
  2. {
  3. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  4. myRequest.Method = "GET";
  5. WebResponse myResponse = myRequest.GetResponse();
  6. StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
  7. string result = sr.ReadToEnd();
  8. sr.Close();
  9. myResponse.Close();
  10. return result;
  11. }

Report this snippet  

You need to login to post a comment.