C#中的HTTP请求

Ere*_*rez 3 c# asp.net http

我需要访问一个URL,在所述页面中找到一个特定的文本框 - 用数据填充它,然后提交一个表单.

我怎样才能在C#中实现这一目标?

PS无辜的意图.

Dan*_*May 5

你最好看一下WebRequest班级(System.Net).

您需要查看POST方法以发布表单(单击提交按钮并填写必填字段).

例:

    // Create a request using a URL that can receive a post. 
    WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx ");
    // Set the Method property of the request to POST.
    request.Method = "POST";
    // Create POST data and convert it to a byte array.
    string postData = "This is a test that posts this string to a Web server.";
    byte[] byteArray = Encoding.UTF8.GetBytes (postData);
Run Code Online (Sandbox Code Playgroud)

有一个很好的教程和大量的信息在MSDN上这里.(上述源代码的延续)