Tools, FAQ, Tutorials:
requests.models.Response Objects
What properties and functions are supported on requests.models.Response objects?
✍: FYIcenter.com
"requests" module supports the following properties and functions on requests.models.Response objects:
>>> r = requests.get() >>> r.status_code >>> r.headers # represents the headers as a dictionary >>> r.text # represents the response body as a strings >>> r.content # represents the response body as a binary >>> r.json() # parses the response body in JSON format >>> r.request # represents the request as requests.models.PreparedRequest >>> dir(r) ['__attrs__', ..., 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 'encoding', 'headers', 'history', 'is_permanent_redirect', 'is_redirect', 'iter_content', 'iter_lines', 'json', 'links', 'next', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url' ]
Here is a Python example on how to access the HTTP response headers:
>>> import requests >>> r = requests.get('http://httpbin.org/get') >>> h = r.headers >>> print(h) {'Connection': 'keep-alive', 'Server': 'gunicorn/19.9.0', 'Date': 'Sun, 12 Aug 2018 21:51:53 GMT', 'Content-Type': 'application/json', 'Content-Length': '265', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true', 'Via': '1.1 vegur' }
⇒ Sending an HTTP POST Request
⇐ Sending an HTTP Request with 'requests'
2022-11-21, 38263🔥, 1💬
Popular Posts:
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to include additional claims in Azure AD v2.0 id_tokens? If you want to include additional claim...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
Where to find tutorials on Microsoft Azure services? Here is a large collection of tutorials to answ...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...