【python-proxy by sockets5】pysocks
pip install pysocks
https://stackoverflow.com/questions/2317849/how-can-i-use-a-socks-4-5-proxy-with-urllib2
https://stackoverflow.com/questions/13184205/dns-over-proxy/13214222#13214222
import socks import socket socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 8080) socket.socket = socks.socksocket def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))] socket.getaddrinfo = getaddrinfo import urllib2 print urllib2.urlopen(url = 'https://www.google.com' , timeout=5).read()