Get location from response header
Question: I am trying to get the `Location` value from a `POST` request using python's
requests module. However, when I look at the response's headers, I don't see
any such key. Performing the same request using Google Chrome does show the
key.

This is where I am trying to download data from: <https://data.police.uk/data>
. Launch this in Google Chrome and open the Developer Tools. When you select a
date range, select some force and click `Generate File`, you can see a `POST`
request being made with a `Location` key in the Response header.

    
    
    import requests
    from urlparse import urlparse, urljoin
    
    BASE = 'https://data.police.uk'
    FORM_PATH = 'data'
    
    form_url = urljoin(BASE, FORM_PATH)
    
    # Get data download URL
    client = requests.session()
    try:
        client.get(form_url)
    except requests.exceptions.ConnectionError as e:
        print (e)
        sys.exit()
    
    csrftoken = client.cookies.values()
    
    l = [('forces', 'cleveland')]
    t = ('csrfmiddlewaretoken', csrftoken[0])
    
    d_from = ('date_from', '2014-05')
    d_to = ('date_to', '2016-05')
    l.extend((t, d_from, d_to))
    
    r = client.post(form_url, headers=dict(Referer=form_url), data=l)
    

Querying the response headers gives me:

    
    
    In [4]: r.headers
    Out[4]: {'Content-Length': '4332', 'Content-Language': 'en-gb', 'Content-Encoding': 'gzip', 'Set-Cookie': 'csrftoken=aGQ7kO4tQ2cPD0Fp2svxxYBRe4rAk0kw; expires=Thu, 03-Aug-2017 22:11:44 GMT; Max-Age=31449600; Path=/', 'Vary': 'Cookie, Accept-Language', 'Server': 'nginx', 'Connection': 'keep-alive', 'Date': 'Thu, 04 Aug 2016 22:11:44 GMT', 'Content-Type': 'text/html; charset=utf-8'}
    

Question: How do I get the `Location` key from the response header?

**EDIT**

Answer: Had to specify `l.append(['include_crime', 'on'])`. Works after this.


Answer: # EDIT2

You need to pass the `include_crime = on` statement as well, since you are not
selecting any dataset. On the webpage if you don't select any checkbox, you
will get the same page and you will not get any location header. That is why
your r.content has "Please select at least one dataset".

