Handling the Response in Python Requests
Author: Newtum
This guide explores the `Response` object that is returned after making a request with the Python Requests library. We will look at accessing the status code, headers, and body of the response.
The Response Object
When you make a request, Requests returns a `Response` object. This object contains all the information sent back by the server.
Status Code
The `status_code` attribute gives you the HTTP status code. You can use this to check if the request was successful (e.g., 200 OK).
Response Headers
The `headers` attribute is a dictionary-like object containing the response headers.
Response Body
You can access the response body in different ways: `.text` for text content (decoded), `.content` for raw binary content, and `.json()` to parse JSON.