Making requests.
Hello, everyone.
Today, we're going to talk about requests and basically the requests allow you to send a request to
HTP server and get responses and messages sent by the server when answering your request.
Obviously, we have the request package available in item so we can actually use it in order to assess
this requests.
Actually go to the Web page of this package.
So you can see here that there the request and the request package.
And from that page, you can simply learn how to use it on Dock's dot python dash requests dot org muster.
And here's everything that you need to know about requests.
And you can follow these links to see the different functionalities of that library.
But anyways, today we're going to do some exact examples, obviously.
First of all, what you need to do if you don't have it installed yet, let me go out of here.
You need to install it by writing pipe to install recall as.
OK, and the ones who do it, this will be installed in your computer.
I don't get the installation because my requirements are already satisfied.
All the package is already installed in my computer.
So the requests library pretty much automates and simplifies the tasks we were doing already.
And I will show you how this is done.
The main thing that we're going to use here is the get the requests functionality.
So here's how it works.
Let's it python.
And here I would type import requests.
OK.
And that's right, response equals requests and don't get.
OK, so now we're getting a request and let's use here give help, so I'll write HTP
and then.
W w w dot good hope.
Dot com.
OK, and here's how we're going to get the request from the GitHub dot com.
So now we did a request to GitHub dot com and the response of this request is in the response, the
message here.
So we collect the answer from Kitco in the response so far.
Right, the terrorists phones.
You see that our response is 200, which means that the data was successfully or the connection with
GitHub was successful completed.
And if you want to see this and work your way, you can see the right response dot status code and you
just get 200.
You can also do a response and thought reason.
And you will get OK, which means that basically everything is OK, or you can simply do response that
you rld and you can see the euro that was highest, which is the get the dot com and you can also do
response.
That's.
Heather's.
And then you can do content dash pie, OK, and you can get the content type, which, as you remember,
is basically the type of the pager to assist.
So it's text slash HTML extra waste text and voice e-mail the same time.
This is just because Hotmail is simply a text file with a code that is in HTML format.
So this demo format is the ones that are the browsers are reading.
So to assess the header properties here, you can simply do a response, not request.
Not Heather's, OK, and once you do that, you can see that the user agent is python slash request.
So this what we use to assess it, then acceptance and coding is cheesy and deflate.
And then we are getting the accept and the connection keys and you can see their responses as well.
So let's finally write response and dot text in order to view the response in a different way, because
you can basically look at it in many ways.
So this is the way that you look at us as a text and you can see how long is the text actually OK,
because it's not always the computer.
Read languages are easy to be understood by humans.
So this is how our response looks as the text actually very, very long one, a lot of lines of code.
But anyways, this was the way, guys, that you can basically work with curios, assess them and check
the different properties of theirs.
That said, thank you very much for watching and I will see you in the next video.