Python Forum

Full Version: disable proxy with requests module
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
doing a simple request with the requests module causes the error below. This error is due to me using a proxy for web browsers only. However i dont want my requests module to use that proxy. Using selenium, or the standard urllib modules does not do the same.

Error:
Traceback (most recent call last):   File "test2.py", line 9, in <module>     soup = bs(requests.get(url).text, 'html.parser')   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/api.py", line 70, in get     return request('get', url, params=params, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/api.py", line 56, in request     return session.request(method=method, url=url, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/sessions.py", line 488, in request     resp = self.send(prep, **send_kwargs)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/sessions.py", line 609, in send     r = adapter.send(request, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/adapters.py", line 390, in send     conn = self.get_connection(request.url, proxies)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/adapters.py", line 290, in get_connection     proxy_manager = self.proxy_manager_for(proxy)   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/adapters.py", line 184, in proxy_manager_for     **proxy_kwargs   File "/usr/local/lib/python2.7/dist-packages/requests-2.11.1-py2.7.egg/requests/adapters.py", line 43, in SOCKSProxyManager     raise InvalidSchema("Missing dependencies for SOCKS support.") requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support.
1) Why does the requests library cause this error?
2) Is there a better way to handle it than to do something like....
import requests
requests = requests.Session()
requests.trust_env = False
...
You can pass a proxy as a parameter to get() method. I've never used it.
See this in SO: http://stackoverflow.com/questions/30837...ion-object

Or you want to bypass it?
that is if you want to add a proxy to your request. Isnt it? I dont want to have a proxy on my request at all, but it is using my browser proxy anyways.