我需要访问一个 URL,在所述页面中找到一个特定的文本框 - 用数据填充它,然后提交一个表单。
我如何在 C# 中完成此操作?
附言无辜的意图。
最佳答案
你最好看看 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);
MSDN 上有一个很好的教程和大量信息 here . (续上源码)
关于c# - C# 中的 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2101628/