Retornando o conteúdo de uma página web
public string GetContent(string url)
{
string result = "Error communicating with server";
System.Net.HttpWebRequest wreq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
wreq.Method = "GET";
wreq.Timeout = 3000;
System.Net.HttpWebResponse wr = (System.Net.HttpWebResponse)wreq.GetResponse();
if (wr.StatusCode == System.Net.HttpStatusCode.OK)
{
System.IO.Stream s = wr.GetResponseStream();
System.Text.Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
System.IO.StreamReader readStream = new System.IO.StreamReader(s, enc);
result = readStream.ReadToEnd();
}
return result;
}
Obrigadoo =)
ResponderEliminar