- Python Automation Cookbook
- Jaime Buelta
- 81字
- 2021-08-13 15:51:10
How it works...
The operation of requests is very simple; perform the operation, GET in this case, over the URL. This returns a result object that can be analyzed. The main elements are the status_code and the body content, which can be presented as text.
The full request can be checked in the request field:
>>> response.request
<PreparedRequest [GET]>
>>> response.request.url
'http://www.columbia.edu/~fdc/sample.html'
The full request's documentation can be found here: http://docs.python-requests.org/en/master/. Over the course of the chapter, we'll be showing more features.