Well, had to put together a quick app today that reads the content of a status web page and send alerts if any errors. There are no services or api’s for me to call to get the status; hence without much thinking went ahead to read the html from the web page and parse through… so had to read html from the url. Here is how I got it done:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
using (Stream stream = request.GetResponse().GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
string response = reader.ReadToEnd();
return response;
}
}
Love coding!
3 comments:
SO, this reads the html code of any page. correct? Then, if I have the HTML code in the string variable, I will be able to compare it the next day if there have been any changes in the web site? Is this possible?
Yes, you should be able to store and compare.
is it possible from c#
Post a Comment