小编Por*_*han的帖子

如何监控网站的变化?

所以我已经为此工作了一个月,但我在网上什么也没找到,所以我认为可能每分钟检查一次网站源代码的变化,但似乎它的源代码每秒都在变化,所以有没有我的编码有问题还是有其他方法可以监控网站的变化?

这是我的代码:

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;
            } …
Run Code Online (Sandbox Code Playgroud)

c# monitoring httpwebrequest httpwebresponse web

5
推荐指数
1
解决办法
6111
查看次数

当我的表单关闭时执行代码

我的程序在运行时对注册表进行了一些更改,如果它们没有正确回滚,可能会给用户带来一些问题。例如,他们可能无法使用互联网连接。

所以我需要确保当他们关闭应用程序时,我将一切恢复正常。为此,我需要知道他们何时按下表单的“关闭”按钮。我怎样才能做到这一点?有我可以处理的事件吗?

.net c# winforms

-1
推荐指数
1
解决办法
5502
查看次数

标签 统计

c# ×2

.net ×1

httpwebrequest ×1

httpwebresponse ×1

monitoring ×1

web ×1

winforms ×1