requests.Session

class requests.Session[source]

A Requests session.

Provides cookie persistence, connection-pooling, and configuration.

Basic Usage:

>>> import requests
>>> s = requests.Session()
>>> s.get('http://httpbin.org/get')
<Response [200]>

Or as a context manager:

>>> with requests.Session() as s:
>>>     s.get('http://httpbin.org/get')
<Response [200]>

Methods

__init__()
close() Closes all adapters and as such the session
delete(url, **kwargs) Sends a DELETE request.
get(url, **kwargs) Sends a GET request.
get_adapter(url) Returns the appropriate connection adapter for the given URL.
head(url, **kwargs) Sends a HEAD request.
merge_environment_settings(url, proxies, ...) Check the environment and merge it with some settings.
mount(prefix, adapter) Registers a connection adapter to a prefix.
options(url, **kwargs) Sends a OPTIONS request.
patch(url[, data]) Sends a PATCH request.
post(url[, data, json]) Sends a POST request.
prepare_request(request) Constructs a PreparedRequest for transmission and returns it.
put(url[, data]) Sends a PUT request.
rebuild_auth(prepared_request, response) When being redirected we may want to strip authentication from the request to avoid leaking credentials.
rebuild_method(prepared_request, response) When being redirected we may want to change the method of the request based on certain specs or browser behavior.
rebuild_proxies(prepared_request, proxies) This method re-evaluates the proxy configuration by considering the environment variables.
request(method, url[, params, data, ...]) Constructs a Request, prepares it and sends it.
resolve_redirects(resp, req[, stream, ...]) Receives a Response.
send(request, **kwargs) Send a given PreparedRequest.