2

Ruby has this very nice gem that allows redirecting all network traffic trough a SOCKS proxy

require 'socksify'
TCPSocket::socks_server = "127.0.0.1"
TCPSocket::socks_port = 9050
rubyforge_www = TCPSocket.new("rubyforge.org", 80)
# => #<TCPSocket:0x...>

Is there any python equivalent?

Luca Martinetti
  • 3,396
  • 6
  • 34
  • 49
  • my super googling skills gave me http://socksipy.sourceforge.net/ and http://sourceforge.net/projects/pysocks/. There is also http://stackoverflow.com/questions/2537726/using-urllib2-with-socks-proxy – Simon Bergot Mar 06 '12 at 15:24

2 Answers2

2

This is quite an old question, but the more current solution would be to use https://github.com/Anorov/PySocks. This has a pip installable package (pip install PySocks) and can be used to monkey-patch socket as so:

import socket
import socks

socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9050)
socket.socket = socks.socksocket
theheadofabroom
  • 20,639
  • 5
  • 33
  • 65
1

Try this: http://socksipy.sourceforge.net/

Cango
  • 100
  • 7