Web ページを 1 時間ごとにチェックするスクリプトをコーディングしたいと考えています。私はSOに関する他の質問を見てきましたが、誰もが使用について話している:
static System.Windows.Forms.Timer t;
誰か助けてくれませんか?
最近は Unix と Linux を見ているので、長い間 C# でコーディングをしていませんでした。
どんな助けでも大歓迎です。
Web ページを 1 時間ごとにチェックするスクリプトをコーディングしたいと考えています。私はSOに関する他の質問を見てきましたが、誰もが使用について話している:
static System.Windows.Forms.Timer t;
誰か助けてくれませんか?
最近は Unix と Linux を見ているので、長い間 C# でコーディングをしていませんでした。
どんな助けでも大歓迎です。
using System;
using System.Net;
using System.Timers;
class Program
{
static void Main()
{
Timer t = new Timer(TimeSpan.FromHours(1).TotalMilliseconds);
t.Elapsed += (sender, e) =>
{
// This code will execute every hour
using (var client = new WebClient())
{
// Send an HTTP request to download the contents of the web page
string result = client.DownloadString("http://www.google.com");
// do something with the results
...
}
};
Console.WriteLine("press any key to stop");
Console.ReadKey();
}
}