So I recently stumbled upon this great library for handling HTTP requests in Python; found here http://docs.python-requests.org/en/latest/index.html.
I love working with it, but I can't figure out how to add headers to my get requests. Help?
According to the api, the headers can all be passed in using requests.get:
Seems pretty straightforward, according to the docs on the page you linked (emphasis mine).
requests.get(url, params=None, headers=None, cookies=None, auth=None, timeout=None)
Sends a GET request. Returns
- url – URL for the new
- params – (optional) Dictionary of GET Parameters to send with the
- headers – (optional) Dictionary of HTTP Headers to send with the
- cookies – (optional) CookieJar object to send with the
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.