In this lesson you will learn about Python requests. Requests is a Python library used to send requests and receive responses. It is a very powerful library and it supports several protocols like Http, Https. And SFTP, just to name a few. Most of the interactions on the Internet. Are based on a request that is. Initiated from some client, like a web browser. And this request goes to a server, like a web server that is hosting a website. Then this server fulfills this request and returns a response back to the client. This is a very common interaction. For example, every time you go to. A website like knowledgecity. com, you are initiating. A request to the web server that. Is hosting this website. Then the server will respond back with. A web page for the client, and. The client will receive this response and. Display the web page. And to do all that in Python. We use the requests library. Now, to use requests in Python, you. First need to install the library, and. You can do this by opening up a terminal window. Then I'll type Pip install requests. And then run it. Now, I already have Requests Library installed. So I get the messages saying so. And by the way, the Pip command is short for Package Installer for Python. And we use it anytime we need to install a library or a third party package to use with Python. Now let me go to a new jupyter And once you have installed Requests, you. Need to import it in your Python. Code by typing Import, which is a reserved keyword in Python, followed by the. Library'S name, which in this case is. Requests all in lowercase letters. So now that we have installed and. Imported the requests library, we can start making Http requests. And to make an HTP request using the requests library, we use the Requests. Get method, which allows us to get. Or fetch some data from a remote location. Again, like a web server. For example, if we want to get. The HTML content of a web page. I can type the following. So this code calls the get method of the request library and passes. It an argument of the website's URL. That I'm trying to fetch the HTML for. Now, this get method will return a response object. And here I assigned it to a variable called response. I could have called the variable name anything I wanted, of course, but I chose the variable name Response to make it descriptive. And once I have a response object, there are some attributes and methods that I can now use. For example, response text will print out the content of the web page, which. Is usually in HTML. So let me run this code, and. Here'S my HTML page that I requested from the website. I could also change the text attribute. Of the response object to status underscore code. And when I run it, I get 200. This is the status code from the server. When everything is fine with my request. And response interactions, I could also change. The status code to be headers. And when I run it, it returns the. Header information of my response which includes. The content type is text, HTML and. The date and time of the response as well as the content's length of this response. Now, just like we can get data. From a remote location like fetching a. Web page, we can also send data to a server. And so the request library also has. A method called Post, which we use to send data instead of receive data. So I'll type the following. So this. Code basically starts with a typical import request statement so I could import this. Library and use it. Then I created a variable called Payload. Which is a dictionary of two key value pairs. The first key is username with a value of example and the second key is password with a value of password. So this is the data that I will be sending and it's in a dictionary format. Then in the next line I call. The post method of the requests library. And this time I not only pass. It the URL, but I specify the. Page as well, which is a login page. And then my second argument is the data that I need to send to. The web server and I must use the word data and assign it my. Data value, which in this case is my variable payload. Then I print out the text of this response object. So I'll go ahead and run it. And I get back a 404 status code which is a file not found message because this is just an example code. But if it was a real and. Active web page that can accept data and send back data, then our output. Here would be different. So in this lesson you learned about. The Python Requests library and stay tuned. For the next lesson where you will. Learn about another popular and powerful library, the Math Library. Thanks for watching.