Whenever a call is made to requests.*() you are doing two major things. First,
you are constructing a ``Request`` object which will be sent of to a server
to request or query some resource. Second, a ``Response`` object is generated
-once ``requests`` gets a response back from the server. The response object
+once ``requests`` gets a response back from the server. The response object
contains all of the information returned by the server and also contains the
``Request`` object you created originally. Here is a simple request to get some
very important information from Wikipedia's servers::
-
+
>>> response = requests.get('http://en.wikipedia.org/wiki/Monty_Python')
If we want to access the headers the server sent back to us, we do this::
-
+
>>> response.headers
{'content-length': '56170', 'x-content-type-options': 'nosniff', 'x-cache':
- 'HIT from cp1006.eqiad.wmnet, MISS from cp1010.eqiad.wmnet', 'content-encoding':
+ 'HIT from cp1006.eqiad.wmnet, MISS from cp1010.eqiad.wmnet', 'content-encoding':
'gzip', 'age': '3080', 'content-language': 'en', 'vary': 'Accept-Encoding,Cookie',
'server': 'Apache', 'last-modified': 'Wed, 13 Jun 2012 01:33:50 GMT',
'connection': 'close', 'cache-control': 'private, s-maxage=0, max-age=0,
{'Accept-Encoding': 'identity, deflate, compress, gzip',
'Accept': '*/*', 'User-Agent': 'python-requests/0.13.1'}
-Requests have these attributes:
-
- * Variable Attributes
- * allow_redirects
- * auth
- * cert
- * config
- * cookies
- * data
- * files
- * headers
- * hooks
- * method
- * params
- * prefetch
- * proxies
- * redirect
- * response
- * sent
- * session
- * timeout
- * url
- * Class Methods
- * deregister_hook
- * full_url
- * path_url
- * register_hook
- * send
-
-Responses have the following attributes:
-
- * Variable Attributes
- * config
- * cookies
- * encoding
- * error
- * headers
- * history
- * raw
- * request
- * status_code
- * url
- * Class Methods
- * content
- * json
- * raise_for_status
- * text
SSL Cert Verification
---------------------