So I've been working on this for a month but I found nothing on the net so I though that it might be possible to check changes in websites source code every minute but it seems it's source code is changing every second, so is there any problem in my coding or is there any other way to monitor a website's changes?
here's my code:
private void Startbtn_Click(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader source = new StreamReader(response.GetResponseStream());
richTextBox1.Text = source.ReadToEnd();
timer1.Start();
timer1.Interval = 60000;
}
private void timer1_Tick(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader source2 = new StreamReader(response.GetResponseStream());
RichTextBox checker = new RichTextBox();
checker.Text = source2.ReadToEnd();
if (richTextBox1.Text == "")
{
richTextBox1.Text = checker.Text;
}
else
{
if (richTextBox1.Text != checker.Text)
{
MessageBox.Show("somthing changed");
richTextBox1.Text = checker.Text;
}
else
{
MessageBox.Show("No changes yet!");
}
}
}
Firstly I would suggest that when have to compare the actual contents of a page to a stored version you:
Some servers will return a Last-Modified
header which you could use to do a compare i guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With