misc/python/socks5-proxy.py

18 lines
457 B
Python
Raw Normal View History

2018-08-05 18:53:07 +02:00
## Patch for request and mechanize which force them to use for through a SOCKS5 proxy
import requests
import socks
import socket
def create_connection(address, timeout=None, source_address=None):
sock = socks.socksocket()
sock.connect(address)
return sock
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9150)
socket.socket = socks.socksocket
socket.create_connection = create_connection
print(requests.get('http://icanhazip.com').text)