HTTP Requests in C #

I need to visit the URL, find a specific text field on the specified page - fill it with data and then submit the form.

How can I do this in C #?

PS Innocent intentions.

+3
source share
2 answers

It is best to look at WebRequestclass (System.Net).

You want to see the POST method for publishing the form (click the submit button with the fields filled in).

Example:

    // 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);

There is a good tutorial here and a lot of information about MSDN here . (Continued above source code)

+5
source

fiddler2, , -.

, , - ( ), , , WebRequest WebClient .net.

WatiN .

0

Source: https://habr.com/ru/post/1729226/


All Articles