18 lines
457 B
Python
18 lines
457 B
Python
|
## 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)
|