In this section, we will learn how to use urllib and requests to interact with HTML forms.
Handling forms with urllib and requests with Python 3.7
Handling forms with urllib
When working with forms, it is useful to use the POST method to send data to the server. The POST method is used for submitting user input from HTML forms and for uploading files to a server.
When using POST, the data that we wish to send will go in the body of the request. We can put any bytes data in there and declare its type by adding a Content-Type header to our request with an appropriate MIME type.
Let's look at an example for sending some HTML form data to a server by using a POST request, just as browsers do when we submit a form on a website...