socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 8080)
socket.socket = socks.socksocket
import urllib.request, urllib.error, urllib.parse
print(urllib.request.urlopen('http://www.google.com').read())
How can I use a SOCKS 4/5 proxy with urllib2?