python request preparedrequest code example

Example: python preparedrequest

The Request is turned into a requests.PreparedRequest when it is sent with .post() or .get(). Unfortunately that doesn't have the unencoded data available anymore.

What you can get from a POST response is login_response.request.body, but that has been encoded as form data at this point.

To turn it back into a nice to use dict you can use this:

# py2
import urlparse
dict(urlparse.parse_qsl(login_response.request.body))
or

# py3
from urllib.parse import parse_qsl
dict(parse_qsl(login_response.request.body))