1

If I supply None or an empty dict to the proxies parameter, requests will automatically fall back to the proxies configured for the operating system as obtained through urllib.request.getproxies() (Python 3) / urllib.getproxies().

import requests
r = requests.get('http://google.com', proxies = {}) # or = None...
print(r.text)

Specifying proxies = { 'http': False } will even cause requests to hang completely for whatever weird reason.

So how do I direct requests to perform HTTP requests directly, without any proxy ?

Arc
  • 11,143
  • 4
  • 52
  • 75

1 Answers1

3

Turns out you have to use an empty string for the protocol you want to use a direct connection:

r = requests.get('http://google.com', proxies = { 'http': '', ... })

Weird, but that's life.

Arc
  • 11,143
  • 4
  • 52
  • 75
  • strangely this doesn't seem to work for me if I set it for a `Session` object, though it works with `requests.get()` **Update**: using `os.environ['HTTPS_PROXY']=''` works – raphael Sep 19 '17 at 20:53
  • (this was because I was explicitly setting `HTTPS_PROXY` in my Windows user environment variables for pip to work) – raphael Sep 19 '17 at 22:20