How to use Socks 5 proxy with Apache HTTP Client 4?

SOCK is a TCP/IP level proxy protocol, not HTTP. It is not supported by HttpClient out of the box. One can customize HttpClient to establish connections via a SOCKS proxy by using a custom connection socket factory EDIT: changes to SSL instead of plain sockets Registry<ConnectionSocketFactory> reg = RegistryBuilder.<ConnectionSocketFactory>create() .register(“http”, PlainConnectionSocketFactory.INSTANCE) .register(“https”, new MyConnectionSocketFactory(SSLContexts.createSystemDefault())) .build(); … Read more

Using urllib2 with SOCKS proxy

Try with pycurl: import pycurl c1 = pycurl.Curl() c1.setopt(pycurl.URL, ‘http://www.google.com’) c1.setopt(pycurl.PROXY, ‘localhost’) c1.setopt(pycurl.PROXYPORT, 8080) c1.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5) c2 = pycurl.Curl() c2.setopt(pycurl.URL, ‘http://www.yahoo.com’) c2.setopt(pycurl.PROXY, ‘localhost’) c2.setopt(pycurl.PROXYPORT, 8081) c2.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5) c1.perform() c2.perform()

Using a socks proxy with git for the http transport

I tested with Git 1.8.2 and SOCKS v5 proxy, following setting works for me: git config –global http.proxy ‘socks5://127.0.0.1:7070’ UPDATE 2017-3-31: According to the document, despite the name http.proxy, it should work for both HTTP and HTTPS repository urls. Thanks @user for pointing out this. UPDATE 2018-11-27: To disable the proxy, run command: git config … Read more

Python urllib over TOR? [duplicate]

The problem is that httplib.HTTPConnection uses the socket module’s create_connection helper function which does the DNS request via the usual getaddrinfo method before connecting the socket. The solution is to make your own create_connection function and monkey-patch it into the socket module before importing urllib2, just like we do with the socket class. import socks … Read more

How can I use a SOCKS 4/5 proxy with urllib2?

You can use SocksiPy module. Simply copy the file “socks.py” to your Python’s lib/site-packages directory, and you’re ready to go. You must use socks before urllib2. (Try it pip install PySocks ) For example: import socks import socket socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, “127.0.0.1”, 8080) socket.socket = socks.socksocket import urllib2 print urllib2.urlopen(‘http://www.google.com’).read() You can also try pycurl lib and … Read more