Working with Forbes, hello, everyone.
Since you covered most of the topics related to how to send the request to a server and see some content
from different bureaus, today I want to talk about forms.
In order to use forms, we need to look at the post method from the Python packages in order to submit
a user input from HTML file or to upload certain files to a server.
So when you use a post method, imagine it as a way to send data in the bottom of the request that we
are making.
And usually it's a good practice that when we put any type of data there, we can also add in the content
by header.
So we know that we're working actually with forms and that our request is the appropriate type.
So let me go now to the Web and show you our website that you can get more information about forums.
So the site is called HTP Bindert Orac and it offers you a test server that returns certain data once
we make a request.
So if you scroll down here and we go to HTML form, you can see an actual form that corresponds to the
post method.
You can see that here we have customer type, customer name, telephone, email address, then it's
site.
So we have different bars here.
They will have selectable buttons, multiple choice time field and delivery instructions.
So it is a pretty good example of how you can post a forum into an e-mail format.
So, for example, here I can type my email address and I can choose different things.
I can choose I, for example, and deliver instructions and then we can submit the form.
So let's do 11 or try.
And you can see that after we submit the form, we're actually getting the message that is released
from that forum.
So we're getting the arguments.
We'll get the header and the header is usually filled with the information that we just.
So here we get the Jassam request to know the IP address in the euro as well.
So this is the code that generates that form, basically, and this is how it will do what we inserted
in this forum.
So, for example, if we're to hear the content type, you can see that the content type is the application
that will double double for euro, then call it.
OK, so here we get a content type, basically.
So let's go now to the idea in this construct, some request that is related to the forms.
Let's write the terminal.
And they may actually increase the size a bit.
OK, so just bite them.
So after we're in the python mode, let's write from your library and request.
Import.
A request.
OK, so now we imported the packages, the package request, and now let's do Rikyu, which is going
to be our object, is to request.
And then inside the brackets, right, h h t p.
And then let's say the name of the site that would just used so it would be called htp bin dot org slash
post Colma data you of and data.
OK, so actually you can see here that we don't define the data type, so data is undefined.
So for that reason I will write data.
You cause the URL.
And quote, and then data there, rectory not.
And cold, and then the brackets, I will simply write UTF eight.
So let's actually hear, since we get on there to create the data dictionary module first and then we'll
continue with the rest of the call.
So what I will do, I will write the data.
Dictionary.
Equals break it and let's add some parameters to the dictionary.
That's right.
Customer.
Now, right here, it's named Martin.
Then let's try the telephone with the customer, so.
Customers telephone, they will put it in parentheses.
OK, and let's.
Right.
Thirty two thousand two hundred thirty three or thirty two, whatever, it actually doesn't matter.
And let's find common size and let's also add parentheses here.
So the sites will be lerche.
And I think that's enough for now.
OK, and actually not just here, guys, that they just missed one sign, so I would just add it.
OK, so now we have the data dictionary and let us know from this data dictionary to create the data
file.
So.
Right, the data equals you Arial library.
Not who you are a parts.
Or actually just pass that you are in cold and right data dictionary.
That's it then.
And code to use here, then code function and then code type will be you T.F. slash eight.
OK.
That's done, and if you get an error here, dismantling the course within that bureau library pass
modules or just do you board your library pass and then run the command once again, that would fix
that error.
So let's us right from your library dot quest.
Import request.
OK, so import the request class and our list right to request equals.
Request and then write the same thing, HTP.
Slush h t t p.
You've been dot org slash post.
And then there you there.
OK, so we're going to get the same issue, but I can see now why it is because here I rotate instead
of Bayardo.
So lame.
Excuse that.
And if I run the same request and I don't get any errors.
OK, so let's add the here and I will write a request that at underscore the header and you can symptomatically
the first and now in the here I will write content type comma in the application slash x.
That's w w w
forward slash, you are l.
Learn, quote.
Same column.
Chavez said, because he utf dush aids.
OK, and let's look better here.
So that's accepted.
And now we should do as a meeting of the request to the Jason Swoboda wants you, of course, eurorail
open and you open the request.
OK.
OK, so right here you are to remember and talk to your opponent.
OK, so if you get a senior right, Leura Labrador's DOT request that you're open and then you will
be able to open actually the request, then let's write response direct, bring quotes Jassam to load
and then the response.
That's it.
Of course, we need to first either Jason also report Jason and then this from the same comment and
you can see that now intercepted separate.
And if we do now print a response there, rectory, you can see that we are getting old arguments that
were previously added.
So the customers, the customers, Martin, on the telephone is three, two, two, three, two.
And the size is large.
OK, you can also see that the header has the same attributes that we added.
So everything seems fine.
You can see also like the address of the origin, so actually created and filled a form into this website
just through the terminal using Python.
So this is how guys, you can actually assess and the date forms on the web just from the terminal and
using Python.
Thank you very much for watching.
And in the next lecture, we're going to continue talking about forms.