Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor changes in a website?

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!");

            }
        }
    }
like image 338
Porphan Avatar asked Nov 13 '22 04:11

Porphan


1 Answers

Firstly I would suggest that when have to compare the actual contents of a page to a stored version you:

  1. Compare a MD5 hash you've stored against the hash of the new one (not the contents everytime)
  2. Remember that there are changing elements in a page that you may not regard as the page content changing...

Some servers will return a Last-Modified header which you could use to do a compare i guess.

like image 166
Quinton Bernhardt Avatar answered Nov 15 '22 13:11

Quinton Bernhardt