Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
disable proxy with requests module
#1
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
...
Recommended Tutorials:
Reply
#2
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?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
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.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 1,900 Mar-10-2022, 11:26 PM
Last Post: Default_001
  Requests module get() incomplete download bobzarm 2 2,486 Feb-17-2021, 04:51 PM
Last Post: bobzarm
  requests module is not working varsh 3 3,749 Sep-10-2020, 03:53 PM
Last Post: buran
  ModuleNotFoundError: No module named "requests" BushFacts 1 5,099 Jan-13-2020, 06:49 AM
Last Post: perfringo
  Proxy Variable in Selenium wont work with FireFox Profile Proxy Setting. MIPython 0 8,489 Jul-13-2018, 05:43 PM
Last Post: MIPython
  An Error in Requests Module pratheep 3 11,868 Feb-06-2018, 05:17 PM
Last Post: pratheep
  Using python requests module and BS4 to login on an Wordpress based website apollo 1 9,369 Feb-06-2018, 01:31 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020