所以我已经为此工作了一个月,但我在网上一无所获,所以我认为可能每分钟检查一次网站源代码的变化,但似乎它的源代码每秒都在变化,所以有没有我的编码有问题还是有其他方法可以监控网站的变化?
这是我的代码:
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!");
}
}
}