1

I would like to try to open a page using proxy requests. https://stackoverflow.com/…/make-requests-using-python-over… I have this code:

def get_tor_session():
session = requests.session()
# Tor uses the 9050 port as the default socks port
session.proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
return session

# Make a request through the Tor connection
# IP visible through Tor
session = get_tor_session()
print(session.get("http://httpbin.org/ip").text)
# Above should print an IP different than your public IP

# Following prints your normal public IP
print(requests.get("http://httpbin.org/ip").text)

But i see:

requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support.

What should I do? Thanks

Zephyr
  • 11,891
  • 53
  • 45
  • 80
Dominik
  • 55
  • 1
  • 2
  • 7

2 Answers2

1

In order to make requests use socks proxy, you need to install it with it's dependency.

pip install requests requests[socks]
ramazan polat
  • 7,111
  • 1
  • 48
  • 76
1

This means that requests is using socks as a proxy and that socks is not installed.

Just run pip install pysocks

denis7
  • 9
  • 1