0

我希望我的 c# 程序在打开网页时调用它。网页中的代码将增加一个计数器......因此我只需要程序来调用页面。不要认为我需要发布或获取或其他任何内容。

想法?

4

2 回答 2

1

欲了解更多信息,请查看 msdn

// Create a request for the URL. 
WebRequest request = WebRequest.Create (
"http://www.contoso.com/default.html");
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams and the response.
reader.Close ();
response.Close ();

如果你不能从上面提取你需要的代码..这里是

WebRequest request = WebRequest.Create ("http://www.mysite.com/counter.php?YourId");
WebResponse response = request.GetResponse();
response.Close ();
于 2013-08-18T21:18:46.457 回答
0

我知道它已经晚了,但对于未来可能会陷入这种情况的人。

System.Net.WebClient client = new System.Net.WebClient();
client.DownloadDataAsync(new Uri("http://stackoverflow.com"));
于 2014-03-28T14:17:43.377 回答