SOCKS5 proxy using urllib2 and PySocks
问题 I'm trying to connect to a SOCKS5 proxy using urllib2 and PySocks. My proxy has a username and password and I use the below code, however I always get a socks.SOCKS5Error: 0x02: Connection not allowed by ruleset message when I'm trying to connect. Would anyone know what I'm doing wrong..? import socket import socks import urllib2 socks.set_default_proxy(socks.SOCKS5, "xx.xx.xx", 8080, 'username','pass') socket.socket = socks.socksocket hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64)