Now let us create our first request for getting a web page, which is very simple. The process includes importing the
requests module, and then getting the web page with the
get method. Let us look into an example:
>>> import requests >>> r = requests.get('http://google.com')
Voila! We are done.
In the preceding example, we get the
requests.get and saving it in the variable
r, which turns out to be the
response object. The
r contains a lot of information about the response, such as header information, content, type of encoding, status code, URL information and many more sophisticated details.
In the same way, we can use all the HTTP request methods like GET, POST, PUT, DELETE, HEAD with ...